Skip to content

Commit 570c819

Browse files
authored
[Fix]remove required kms_arn in Export (#374)
* remove required kms_arn in Export * fix test * handle null check
1 parent 4cd6bc0 commit 570c819

3 files changed

Lines changed: 23 additions & 12 deletions

File tree

docs/resources/namespace_export_sink.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ Required:
5353

5454
- `aws_account_id` (String) The AWS account ID associated with the S3 bucket and the assumed role.
5555
- `bucket_name` (String) The name of the destination S3 bucket where Temporal will send data.
56-
- `kms_arn` (String) The AWS Key Management Service (KMS) ARN used for encryption.
5756
- `region` (String) The region where the S3 bucket is located.
5857
- `role_name` (String) The IAM role that Temporal Cloud assumes for writing records to the customer's S3 bucket.
5958

59+
Optional:
60+
61+
- `kms_arn` (String) The AWS Key Management Service (KMS) ARN used for encryption.
62+
6063

6164
<a id="nestedblock--timeouts"></a>
6265
### Nested Schema for `timeouts`

internal/provider/namespace_export_sink_resource.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (r *namespaceExportSinkResource) Schema(ctx context.Context, req resource.S
146146
},
147147
"kms_arn": schema.StringAttribute{
148148
Description: "The AWS Key Management Service (KMS) ARN used for encryption.",
149-
Required: true,
149+
Optional: true,
150150
},
151151
"aws_account_id": schema.StringAttribute{
152152
Description: "The AWS account ID associated with the S3 bucket and the assumed role.",
@@ -274,9 +274,13 @@ func updateSinkModelFromSpec(ctx context.Context, state *namespaceExportSinkReso
274274
RoleName: types.StringValue(sink.GetSpec().GetS3().GetRoleName()),
275275
BucketName: types.StringValue(sink.GetSpec().GetS3().GetBucketName()),
276276
Region: types.StringValue(sink.GetSpec().GetS3().GetRegion()),
277-
KmsArn: types.StringValue(sink.GetSpec().GetS3().GetKmsArn()),
278277
AwsAccountId: types.StringValue(sink.GetSpec().GetS3().GetAwsAccountId()),
279278
}
279+
280+
if sink.GetSpec().GetS3().GetKmsArn() != "" {
281+
s3Spec.KmsArn = types.StringValue(sink.GetSpec().GetS3().GetKmsArn())
282+
}
283+
280284
s3Obj, diags = types.ObjectValueFrom(ctx, internaltypes.S3SpecModelAttrTypes, s3Spec)
281285
diags.Append(diags...)
282286
if diags.HasError() {
@@ -411,16 +415,22 @@ func getSinkSpecFromModel(ctx context.Context, plan *namespaceExportSinkResource
411415
return nil, diags
412416
}
413417

418+
s3SinkSpec := &sinkv1.S3Spec{
419+
RoleName: s3Spec.RoleName.ValueString(),
420+
BucketName: s3Spec.BucketName.ValueString(),
421+
Region: s3Spec.Region.ValueString(),
422+
KmsArn: s3Spec.KmsArn.ValueString(),
423+
AwsAccountId: s3Spec.AwsAccountId.ValueString(),
424+
}
425+
426+
if !s3Spec.KmsArn.IsNull() {
427+
s3SinkSpec.KmsArn = s3Spec.KmsArn.ValueString()
428+
}
429+
414430
return &namespacev1.ExportSinkSpec{
415431
Name: plan.SinkName.ValueString(),
416432
Enabled: plan.Enabled.ValueBool(),
417-
S3: &sinkv1.S3Spec{
418-
RoleName: s3Spec.RoleName.ValueString(),
419-
BucketName: s3Spec.BucketName.ValueString(),
420-
Region: s3Spec.Region.ValueString(),
421-
KmsArn: s3Spec.KmsArn.ValueString(),
422-
AwsAccountId: s3Spec.AwsAccountId.ValueString(),
423-
},
433+
S3: s3SinkSpec,
424434
}, nil
425435
} else if !plan.Gcs.IsNull() {
426436
var gcsSpec internaltypes.GCSSpecModel

internal/provider/namespace_export_sink_resource_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ func TestAccNamespaceExportSink_S3(t *testing.T) {
5050
resource.TestCheckResourceAttr("temporalcloud_namespace_export_sink.test", "s3.region", sinkRegion),
5151
resource.TestCheckResourceAttr("temporalcloud_namespace_export_sink.test", "s3.role_name", "test-role"),
5252
resource.TestCheckResourceAttr("temporalcloud_namespace_export_sink.test", "s3.aws_account_id", "123456789012"),
53-
resource.TestCheckResourceAttr("temporalcloud_namespace_export_sink.test", "s3.kms_arn", "arn:aws:kms:us-east-1:123456789012:key/test-key"),
5453
),
5554
},
5655
// ImportState testing
@@ -186,7 +185,6 @@ resource "temporalcloud_namespace_export_sink" "test" {
186185
region = %[4]q
187186
role_name = "test-role"
188187
aws_account_id = "123456789012"
189-
kms_arn = "arn:aws:kms:us-east-1:123456789012:key/test-key"
190188
}
191189
192190
}

0 commit comments

Comments
 (0)