Skip to content

Commit

Permalink
Merge pull request #31006 from hashicorp/f-deprecate-aws_redshift_ser…
Browse files Browse the repository at this point in the history
…vice_account

d/aws_redshift_service_account: Deprecate
  • Loading branch information
ewbankkit authored Apr 26, 2023
2 parents ec9ea3b + 68c6c12 commit 74a2a07
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 77 deletions.
3 changes: 3 additions & 0 deletions .changelog/31006.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:note
data-source/aws_db_security_group: The `aws_redshift_service_account` data source has been deprecated and will be removed in a future version. AWS documentation [states that](https://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html#db-auditing-bucket-permissions) a [service principal name](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-services) should be used instead of an AWS account ID in any relevant IAM policy
```
10 changes: 4 additions & 6 deletions internal/service/redshift/cluster_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ data "aws_redshift_cluster" "test" {

func testAccClusterDataSourceConfig_logging(rName string) string {
return fmt.Sprintf(`
data "aws_redshift_service_account" "test" {}
resource "aws_s3_bucket" "test" {
bucket = %[1]q
force_destroy = true
Expand All @@ -193,8 +191,8 @@ data "aws_iam_policy_document" "test" {
resources = ["${aws_s3_bucket.test.arn}/*"]
principals {
identifiers = [data.aws_redshift_service_account.test.arn]
type = "AWS"
type = "Service"
identifiers = ["redshift.amazonaws.com"]
}
}
Expand All @@ -203,8 +201,8 @@ data "aws_iam_policy_document" "test" {
resources = [aws_s3_bucket.test.arn]
principals {
identifiers = [data.aws_redshift_service_account.test.arn]
type = "AWS"
type = "Service"
identifiers = ["redshift.amazonaws.com"]
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions internal/service/redshift/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1198,8 +1198,6 @@ func testAccClusterConfig_loggingEnabled(rName string) string {
return acctest.ConfigCompose(acctest.ConfigAvailableAZsNoOptInExclude("usw2-az2"), fmt.Sprintf(`
data "aws_partition" "current" {}
data "aws_redshift_service_account" "main" {}
resource "aws_s3_bucket" "test" {
bucket = %[1]q
force_destroy = true
Expand All @@ -1215,7 +1213,7 @@ resource "aws_s3_bucket_policy" "test" {
"Sid": "Stmt1376526643067",
"Effect": "Allow",
"Principal": {
"AWS": "${data.aws_redshift_service_account.main.arn}"
"Service": "redshift.${data.aws_partition.current.dns_suffix}"
},
"Action": "s3:PutObject",
"Resource": "arn:${data.aws_partition.current.partition}:s3:::%[1]s/*"
Expand All @@ -1224,7 +1222,7 @@ resource "aws_s3_bucket_policy" "test" {
"Sid": "Stmt137652664067",
"Effect": "Allow",
"Principal": {
"AWS": "${data.aws_redshift_service_account.main.arn}"
"Service": "redshift.${data.aws_partition.current.dns_suffix}"
},
"Action": "s3:GetBucketAcl",
"Resource": "arn:${data.aws_partition.current.partition}:s3:::%[1]s"
Expand Down
2 changes: 2 additions & 0 deletions internal/service/redshift/service_account_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func DataSourceServiceAccount() *schema.Resource {
Computed: true,
},
},

DeprecationMessage: `The aws_redshift_service_account data source has been deprecated and will be removed in a future version. Use a service principal name instead of AWS account ID in any relevant IAM policy.`,
}
}

Expand Down
66 changes: 0 additions & 66 deletions internal/service/redshift/service_account_data_source_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion website/docs/d/redshift_service_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Use this data source to get the Account ID of the [AWS Redshift Service Account]
in a given region for the purpose of allowing Redshift to store audit data in S3.

~> **Note:** AWS documentation [states that](https://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html#db-auditing-bucket-permissions) a [service principal name](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-services) should be used instead of an AWS account ID in any relevant IAM policy.
The `aws_redshift_service_account` data source should now be considered deprecated and will be removed in a future version.
The `aws_redshift_service_account` data source has been deprecated and will be removed in a future version.

## Example Usage

Expand Down

0 comments on commit 74a2a07

Please sign in to comment.