mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
When you need to enable monitoring for Redshift, you need to create the correct policy in the bucket for logging. This needs to have the Redshift Account ID for a given region. This data source provides a handy lookup for this http://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html#db-auditing-enable-logging % make testacc TEST=./builtin/providers/aws % TESTARGS='-run=TestAccAWSRedshiftAccountId_basic' 2 ↵ ✹ ✭ ==> Checking that code complies with gofmt requirements... /Users/stacko/Code/go/bin/stringer go generate $(go list ./... | grep -v /terraform/vendor/) 2016/08/16 14:39:35 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSRedshiftAccountId_basic -timeout 120m === RUN TestAccAWSRedshiftAccountId_basic --- PASS: TestAccAWSRedshiftAccountId_basic (19.47s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 19.483s
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package aws
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
)
|
|
|
|
// See http://docs.aws.amazon.com/redshift/latest/mgmt/db-auditing.html#db-auditing-enable-logging
|
|
var redshiftServiceAccountPerRegionMap = map[string]string{
|
|
"us-east-1": "193672423079",
|
|
"us-west-1": "262260360010",
|
|
"us-west-2": "902366379725",
|
|
"ap-south-1": "865932855811",
|
|
"ap-northeast-2": "760740231472",
|
|
"ap-southeast-1": "361669875840",
|
|
"ap-southeast-2": "762762565011",
|
|
"ap-northeast-1": "404641285394",
|
|
"eu-central-1": "053454850223",
|
|
"eu-west-1": "210876761215",
|
|
}
|
|
|
|
func dataSourceAwsRedshiftServiceAccount() *schema.Resource {
|
|
return &schema.Resource{
|
|
Read: dataSourceAwsRedshiftServiceAccountRead,
|
|
|
|
Schema: map[string]*schema.Schema{
|
|
"region": &schema.Schema{
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func dataSourceAwsRedshiftServiceAccountRead(d *schema.ResourceData, meta interface{}) error {
|
|
region := meta.(*AWSClient).region
|
|
if v, ok := d.GetOk("region"); ok {
|
|
region = v.(string)
|
|
}
|
|
|
|
if accid, ok := redshiftServiceAccountPerRegionMap[region]; ok {
|
|
d.SetId(accid)
|
|
return nil
|
|
}
|
|
|
|
return fmt.Errorf("Unknown region (%q)", region)
|
|
}
|