Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding expiration_date field to IAM and Service Credentials #5195

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ func DataSourceIbmSmIamCredentialsSecret() *schema.Resource {
Computed: true,
Description: "The time-to-live (TTL) or lease duration to assign to generated credentials.For `iam_credentials` secrets, the TTL defines for how long each generated API key remains valid. The value can be either an integer that specifies the number of seconds, or the string representation of a duration, such as `120m` or `24h`.Minimum duration is 1 minute. Maximum is 90 days.",
},
"expiration_date": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The date a secret is expired. The date format follows RFC 3339.",
},
"access_groups": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -307,6 +312,11 @@ func dataSourceIbmSmIamCredentialsSecretRead(context context.Context, d *schema.
return diag.FromErr(fmt.Errorf("Error setting api_key: %s", err))
}

if iAMCredentialsSecret.ExpirationDate != nil {
if err = d.Set("expiration_date", DateTimeToRFC3339(iAMCredentialsSecret.ExpirationDate)); err != nil {
return diag.FromErr(fmt.Errorf("Error setting expiration_date: %s", err))
}
}
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ func DataSourceIbmSmIamCredentialsSecretMetadata() *schema.Resource {
Computed: true,
Description: "The time-to-live (TTL) or lease duration to assign to generated credentials.For `iam_credentials` secrets, the TTL defines for how long each generated API key remains valid. The value can be either an integer that specifies the number of seconds, or the string representation of a duration, such as `120m` or `24h`.Minimum duration is 1 minute. Maximum is 90 days.",
},
"expiration_date": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The date a secret is expired. The date format follows RFC 3339.",
},
"access_groups": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -302,6 +307,12 @@ func dataSourceIbmSmIamCredentialsSecretMetadataRead(context context.Context, d
return diag.FromErr(fmt.Errorf("Error setting next_rotation_date: %s", err))
}

if iAMCredentialsSecretMetadata.ExpirationDate != nil {
if err = d.Set("expiration_date", DateTimeToRFC3339(iAMCredentialsSecretMetadata.ExpirationDate)); err != nil {
return diag.FromErr(fmt.Errorf("Error setting expiration_date: %s", err))
}
}

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ func DataSourceIbmSmServiceCredentialsSecret() *schema.Resource {
Computed: true,
Description: "The time-to-live (TTL) or lease duration to assign to generated credentials.",
},
"expiration_date": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The date a secret is expired. The date format follows RFC 3339.",
},
"rotation": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -398,6 +403,12 @@ func dataSourceIbmSmServiceCredentialsSecretRead(context context.Context, d *sch
}
}

if ServiceCredentialsSecret.ExpirationDate != nil {
if err = d.Set("expiration_date", DateTimeToRFC3339(ServiceCredentialsSecret.ExpirationDate)); err != nil {
return diag.FromErr(fmt.Errorf("Error setting expiration_date: %s", err))
}
}

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ func DataSourceIbmSmServiceCredentialsSecretMetadata() *schema.Resource {
Computed: true,
Description: "The time-to-live (TTL) or lease duration to assign to generated credentials.",
},
"expiration_date": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The date a secret is expired. The date format follows RFC 3339.",
},
"rotation": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -386,6 +391,12 @@ func dataSourceIbmSmServiceCredentialsSecretMetadataRead(context context.Context
}
}

if ServiceCredentialsSecretMetadata.ExpirationDate != nil {
if err = d.Set("expiration_date", DateTimeToRFC3339(ServiceCredentialsSecretMetadata.ExpirationDate)); err != nil {
return diag.FromErr(fmt.Errorf("Error setting expiration_date: %s", err))
}
}

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func ResourceIbmSmIamCredentialsSecret() *schema.Resource {
ValidateFunc: StringIsIntBetween(60, 7776000),
Description: "The time-to-live (TTL) or lease duration to assign to generated credentials.For `iam_credentials` secrets, the TTL defines for how long each generated API key remains valid. The value is an integer that specifies the number of seconds .Minimum duration is 1 minute. Maximum is 90 days.",
},
"expiration_date": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The date a secret is expired. The date format follows RFC 3339.",
},
"access_groups": &schema.Schema{
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -425,6 +430,12 @@ func resourceIbmSmIamCredentialsSecretRead(context context.Context, d *schema.Re
}
}

if secret.ExpirationDate != nil {
if err = d.Set("expiration_date", DateTimeToRFC3339(secret.ExpirationDate)); err != nil {
return diag.FromErr(fmt.Errorf("Error setting expiration_date: %s", err))
}
}

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,15 @@ func ResourceIbmSmServiceCredentialsSecret() *schema.Resource {
},
"ttl": &schema.Schema{
Type: schema.TypeString,
Required: true,
Optional: true,
avirib marked this conversation as resolved.
Show resolved Hide resolved
Computed: true,
Description: "The time-to-live (TTL) or lease duration to assign to generated credentials.",
},
"expiration_date": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Description: "The date a secret is expired. The date format follows RFC 3339.",
},
"updated_at": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -464,6 +470,12 @@ func resourceIbmSmServiceCredentialsSecretRead(context context.Context, d *schem
}
}

if secret.ExpirationDate != nil {
if err = d.Set("expiration_date", DateTimeToRFC3339(secret.ExpirationDate)); err != nil {
return diag.FromErr(fmt.Errorf("Error setting expiration_date: %s", err))
}
}

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func TestAccIbmSmServiceCredentialsSecretAllArgs(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "next_rotation_date"),
resource.TestCheckResourceAttr(resourceName, "state", "1"),
resource.TestCheckResourceAttr(resourceName, "versions_total", "1"),
resource.TestCheckResourceAttr(resourceName, "ttl", serviceCredentialsTtl),
),
},
resource.TestStep{
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/sm_iam_credentials_secret.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,4 @@ Nested scheme for **rotation**:
* `versions_total` - (Integer) The number of versions of the secret.
* Constraints: The maximum value is `50`. The minimum value is `0`.

* `expiration_date` - (String) The date a secret is expired. The date format follows RFC 3339.
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,4 @@ Nested scheme for **rotation**:
* `versions_total` - (Integer) The number of versions of the secret.
* Constraints: The maximum value is `50`. The minimum value is `0`.

* `expiration_date` - (String) The date a secret is expired. The date format follows RFC 3339.
1 change: 1 addition & 0 deletions website/docs/d/sm_service_credentials_secret.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,4 @@ In addition to all argument references listed, you can access the following attr
* `versions_total` - (Integer) The number of versions of the secret.
* Constraints: The maximum value is `50`. The minimum value is `0`.

* `expiration_date` - (String) The date a secret is expired. The date format follows RFC 3339.
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,4 @@ In addition to all argument references listed, you can access the following attr
* `versions_total` - (Integer) The number of versions of the secret.
* Constraints: The maximum value is `50`. The minimum value is `0`.

* `expiration_date` - (String) The date a secret is expired. The date format follows RFC 3339.
3 changes: 2 additions & 1 deletion website/docs/r/sm_iam_credentials_secret.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ In addition to all argument references listed, you can access the following attr
* Constraints: Allowable values are: `arbitrary`, `imported_cert`, `public_cert`, `iam_credentials`, `kv`, `username_password`, `private_cert`.
* `updated_at` - (String) The date when a resource was recently modified. The date format follows RFC 3339.
* `versions_total` - (Integer) The number of versions of the secret.
* Constraints: The maximum value is `50`. The minimum value is `0`.
* Constraints: The maximum value is `50`. The minimum value is `0`.
* `expiration_date` - (String) The date a secret is expired. The date format follows RFC 3339.

## Provider Configuration

Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/sm_service_credentials_secret.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ In addition to all argument references listed, you can access the following attr
* Constraints: Allowable values are: `arbitrary`, `imported_cert`, `public_cert`, `iam_credentials`, `kv`, `username_password`, `private_cert`.
* `updated_at` - (String) The date when a resource was recently modified. The date format follows RFC 3339.
* `versions_total` - (Integer) The number of versions of the secret.
* Constraints: The maximum value is `50`. The minimum value is `0`.
* Constraints: The maximum value is `50`. The minimum value is `0`.
* `expiration_date` - (String) The date a secret is expired. The date format follows RFC 3339.

## Provider Configuration

Expand Down
Loading