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

Fix Sagemaker Domain KMS Key ID fields #32661

Merged
merged 3 commits into from
Aug 15, 2023
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
3 changes: 3 additions & 0 deletions .changelog/32661.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_sagemaker_domain: Fix validation on `s3_kms_key_id` in `sharing_settings` and `kms_key_id`
```
12 changes: 5 additions & 7 deletions internal/service/sagemaker/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,8 @@ func ResourceDomain() *schema.Resource {
ValidateFunc: validation.StringInSlice(sagemaker.NotebookOutputOption_Values(), false),
},
"s3_kms_key_id": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: verify.ValidARN,
Type: schema.TypeString,
Optional: true,
},
"s3_output_path": {
Type: schema.TypeString,
Expand Down Expand Up @@ -650,10 +649,9 @@ func ResourceDomain() *schema.Resource {
Computed: true,
},
"kms_key_id": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
ValidateFunc: verify.ValidARN,
Type: schema.TypeString,
ForceNew: true,
Optional: true,
},
"retention_policy": {
Type: schema.TypeList,
Expand Down
10 changes: 5 additions & 5 deletions internal/service/sagemaker/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func testAccDomain_kms(t *testing.T) {
Config: testAccDomainConfig_kms(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckDomainExists(ctx, resourceName, &domain),
resource.TestCheckResourceAttrPair(resourceName, "kms_key_id", "aws_kms_key.test", "arn"),
resource.TestCheckResourceAttrPair(resourceName, "kms_key_id", "aws_kms_key.test", "key_id"),
),
},
{
Expand Down Expand Up @@ -233,7 +233,7 @@ func testAccDomain_sharingSettings(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "default_user_settings.#", "1"),
resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.sharing_settings.#", "1"),
resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.sharing_settings.0.notebook_output_option", "Allowed"),
resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.sharing_settings.0.s3_kms_key_id", "aws_kms_key.test", "arn"),
resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.sharing_settings.0.s3_kms_key_id", "aws_kms_key.test", "key_id"),
resource.TestCheckResourceAttrSet(resourceName, "default_user_settings.0.sharing_settings.0.s3_output_path"),
),
},
Expand Down Expand Up @@ -751,7 +751,7 @@ func testAccDomain_defaultUserSettingsUpdated(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "default_user_settings.#", "1"),
resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.sharing_settings.#", "1"),
resource.TestCheckResourceAttr(resourceName, "default_user_settings.0.sharing_settings.0.notebook_output_option", "Allowed"),
resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.sharing_settings.0.s3_kms_key_id", "aws_kms_key.test", "arn"),
resource.TestCheckResourceAttrPair(resourceName, "default_user_settings.0.sharing_settings.0.s3_kms_key_id", "aws_kms_key.test", "key_id"),
resource.TestCheckResourceAttrSet(resourceName, "default_user_settings.0.sharing_settings.0.s3_output_path"),
),
},
Expand Down Expand Up @@ -954,7 +954,7 @@ resource "aws_sagemaker_domain" "test" {
auth_mode = "IAM"
vpc_id = aws_vpc.test.id
subnet_ids = aws_subnet.test[*].id
kms_key_id = aws_kms_key.test.arn
kms_key_id = aws_kms_key.test.key_id

default_user_settings {
execution_role = aws_iam_role.test.arn
Expand Down Expand Up @@ -1098,7 +1098,7 @@ resource "aws_sagemaker_domain" "test" {

sharing_settings {
notebook_output_option = "Allowed"
s3_kms_key_id = aws_kms_key.test.arn
s3_kms_key_id = aws_kms_key.test.key_id
s3_output_path = "s3://${aws_s3_bucket.test.bucket}/sharing"
}
}
Expand Down
Loading