Add partition to remaining ARN builders.
This commit is contained in:
parent
1f8c2e4c69
commit
a8e68ab25e
|
@ -155,20 +155,23 @@ func resourceAwsDbEventSubscriptionRead(d *schema.ResourceData, meta interface{}
|
|||
// list tags for resource
|
||||
// set tags
|
||||
conn := meta.(*AWSClient).rdsconn
|
||||
arn := buildRDSEventSubscriptionARN(d.Get("customer_aws_id").(string), d.Id(), meta.(*AWSClient).region)
|
||||
resp, err := conn.ListTagsForResource(&rds.ListTagsForResourceInput{
|
||||
ResourceName: aws.String(arn),
|
||||
})
|
||||
if arn, err := buildRDSEventSubscriptionARN(d.Get("customer_aws_id").(string), d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).region); err != nil {
|
||||
log.Printf("[DEBUG] Error building ARN for RDS Event Subscription, not setting Tags for Event Subscription %s", *sub.CustSubscriptionId)
|
||||
} else {
|
||||
resp, err := conn.ListTagsForResource(&rds.ListTagsForResourceInput{
|
||||
ResourceName: aws.String(arn),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Printf("[DEBUG] Error retrieving tags for ARN: %s", arn)
|
||||
}
|
||||
if err != nil {
|
||||
log.Printf("[DEBUG] Error retrieving tags for ARN: %s", arn)
|
||||
}
|
||||
|
||||
var dt []*rds.Tag
|
||||
if len(resp.TagList) > 0 {
|
||||
dt = resp.TagList
|
||||
var dt []*rds.Tag
|
||||
if len(resp.TagList) > 0 {
|
||||
dt = resp.TagList
|
||||
}
|
||||
d.Set("tags", tagsToMapRDS(dt))
|
||||
}
|
||||
d.Set("tags", tagsToMapRDS(dt))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -261,11 +264,12 @@ func resourceAwsDbEventSubscriptionUpdate(d *schema.ResourceData, meta interface
|
|||
d.SetPartial("source_type")
|
||||
}
|
||||
|
||||
arn := buildRDSEventSubscriptionARN(d.Get("customer_aws_id").(string), d.Id(), meta.(*AWSClient).region)
|
||||
if err := setTagsRDS(rdsconn, d, arn); err != nil {
|
||||
return err
|
||||
} else {
|
||||
d.SetPartial("tags")
|
||||
if arn, err := buildRDSEventSubscriptionARN(d.Get("customer_aws_id").(string), d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).region); err == nil {
|
||||
if err := setTagsRDS(rdsconn, d, arn); err != nil {
|
||||
return err
|
||||
} else {
|
||||
d.SetPartial("tags")
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("source_ids") {
|
||||
|
@ -372,7 +376,10 @@ func resourceAwsDbEventSubscriptionRefreshFunc(
|
|||
}
|
||||
}
|
||||
|
||||
func buildRDSEventSubscriptionARN(customerAwsId, subscriptionId, region string) string {
|
||||
arn := fmt.Sprintf("arn:aws:rds:%s:%s:es:%s", region, customerAwsId, subscriptionId)
|
||||
return arn
|
||||
func buildRDSEventSubscriptionARN(customerAwsId, subscriptionId, partition, region string) (string, error) {
|
||||
if partition == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS ARN because of missing AWS partition")
|
||||
}
|
||||
arn := fmt.Sprintf("arn:%s:rds:%s:%s:es:%s", partition, region, customerAwsId, subscriptionId)
|
||||
return arn, nil
|
||||
}
|
||||
|
|
|
@ -1053,6 +1053,9 @@ func resourceAwsDbInstanceStateRefreshFunc(
|
|||
}
|
||||
|
||||
func buildRDSARN(identifier, partition, accountid, region string) (string, error) {
|
||||
if partition == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS ARN because of missing AWS partition")
|
||||
}
|
||||
if accountid == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS ARN because of missing AWS Account ID")
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ func resourceAwsDbOptionGroupRead(d *schema.ResourceData, meta interface{}) erro
|
|||
}
|
||||
|
||||
optionGroup := options.OptionGroupsList[0]
|
||||
arn, err := buildRDSOptionGroupARN(d.Id(), meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
arn, err := buildRDSOptionGroupARN(d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
if err != nil {
|
||||
name := "<empty>"
|
||||
if optionGroup.OptionGroupName != nil && *optionGroup.OptionGroupName != "" {
|
||||
|
@ -261,7 +261,7 @@ func resourceAwsDbOptionGroupUpdate(d *schema.ResourceData, meta interface{}) er
|
|||
|
||||
}
|
||||
|
||||
if arn, err := buildRDSOptionGroupARN(d.Id(), meta.(*AWSClient).accountid, meta.(*AWSClient).region); err == nil {
|
||||
if arn, err := buildRDSOptionGroupARN(d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).accountid, meta.(*AWSClient).region); err == nil {
|
||||
if err := setTagsRDS(rdsconn, d, arn); err != nil {
|
||||
return err
|
||||
} else {
|
||||
|
@ -333,11 +333,14 @@ func resourceAwsDbOptionHash(v interface{}) int {
|
|||
return hashcode.String(buf.String())
|
||||
}
|
||||
|
||||
func buildRDSOptionGroupARN(identifier, accountid, region string) (string, error) {
|
||||
func buildRDSOptionGroupARN(identifier, partition, accountid, region string) (string, error) {
|
||||
if partition == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS Option Group ARN because of missing AWS partition")
|
||||
}
|
||||
if accountid == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS Option Group ARN because of missing AWS Account ID")
|
||||
}
|
||||
arn := fmt.Sprintf("arn:aws:rds:%s:%s:og:%s", region, accountid, identifier)
|
||||
arn := fmt.Sprintf("arn:%s:rds:%s:%s:og:%s", partition, region, accountid, identifier)
|
||||
return arn, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) e
|
|||
d.Set("parameter", flattenParameters(describeParametersResp.Parameters))
|
||||
|
||||
paramGroup := describeResp.DBParameterGroups[0]
|
||||
arn, err := buildRDSPGARN(d.Id(), meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
arn, err := buildRDSPGARN(d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
if err != nil {
|
||||
name := "<empty>"
|
||||
if paramGroup.DBParameterGroupName != nil && *paramGroup.DBParameterGroupName != "" {
|
||||
|
@ -217,7 +217,7 @@ func resourceAwsDbParameterGroupUpdate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
}
|
||||
|
||||
if arn, err := buildRDSPGARN(d.Id(), meta.(*AWSClient).accountid, meta.(*AWSClient).region); err == nil {
|
||||
if arn, err := buildRDSPGARN(d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).accountid, meta.(*AWSClient).region); err == nil {
|
||||
if err := setTagsRDS(rdsconn, d, arn); err != nil {
|
||||
return err
|
||||
} else {
|
||||
|
@ -278,11 +278,14 @@ func resourceAwsDbParameterHash(v interface{}) int {
|
|||
return hashcode.String(buf.String())
|
||||
}
|
||||
|
||||
func buildRDSPGARN(identifier, accountid, region string) (string, error) {
|
||||
func buildRDSPGARN(identifier, partition, accountid, region string) (string, error) {
|
||||
if partition == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS ARN because of missing AWS partition")
|
||||
}
|
||||
if accountid == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS ARN because of missing AWS Account ID")
|
||||
}
|
||||
arn := fmt.Sprintf("arn:aws:rds:%s:%s:pg:%s", region, accountid, identifier)
|
||||
arn := fmt.Sprintf("arn:%s:rds:%s:%s:pg:%s", partition, region, accountid, identifier)
|
||||
return arn, nil
|
||||
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ func resourceAwsDbSecurityGroupRead(d *schema.ResourceData, meta interface{}) er
|
|||
d.Set("ingress", rules)
|
||||
|
||||
conn := meta.(*AWSClient).rdsconn
|
||||
arn, err := buildRDSSecurityGroupARN(d.Id(), meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
arn, err := buildRDSSecurityGroupARN(d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
if err != nil {
|
||||
name := "<empty>"
|
||||
if sg.DBSecurityGroupName != nil && *sg.DBSecurityGroupName != "" {
|
||||
|
@ -207,7 +207,7 @@ func resourceAwsDbSecurityGroupUpdate(d *schema.ResourceData, meta interface{})
|
|||
conn := meta.(*AWSClient).rdsconn
|
||||
|
||||
d.Partial(true)
|
||||
if arn, err := buildRDSSecurityGroupARN(d.Id(), meta.(*AWSClient).accountid, meta.(*AWSClient).region); err == nil {
|
||||
if arn, err := buildRDSSecurityGroupARN(d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).accountid, meta.(*AWSClient).region); err == nil {
|
||||
if err := setTagsRDS(conn, d, arn); err != nil {
|
||||
return err
|
||||
} else {
|
||||
|
@ -421,11 +421,14 @@ func resourceAwsDbSecurityGroupStateRefreshFunc(
|
|||
}
|
||||
}
|
||||
|
||||
func buildRDSSecurityGroupARN(identifier, accountid, region string) (string, error) {
|
||||
func buildRDSSecurityGroupARN(identifier, partition, accountid, region string) (string, error) {
|
||||
if partition == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS ARN because of missing AWS partition")
|
||||
}
|
||||
if accountid == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS ARN because of missing AWS Account ID")
|
||||
}
|
||||
arn := fmt.Sprintf("arn:aws:rds:%s:%s:secgrp:%s", region, accountid, identifier)
|
||||
arn := fmt.Sprintf("arn:%s:rds:%s:%s:secgrp:%s", partition, region, accountid, identifier)
|
||||
return arn, nil
|
||||
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) erro
|
|||
// list tags for resource
|
||||
// set tags
|
||||
conn := meta.(*AWSClient).rdsconn
|
||||
arn, err := buildRDSsubgrpARN(d.Id(), meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
arn, err := buildRDSsubgrpARN(d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
if err != nil {
|
||||
log.Printf("[DEBUG] Error building ARN for DB Subnet Group, not setting Tags for group %s", *subnetGroup.DBSubnetGroupName)
|
||||
} else {
|
||||
|
@ -178,7 +178,7 @@ func resourceAwsDbSubnetGroupUpdate(d *schema.ResourceData, meta interface{}) er
|
|||
}
|
||||
}
|
||||
|
||||
if arn, err := buildRDSsubgrpARN(d.Id(), meta.(*AWSClient).accountid, meta.(*AWSClient).region); err == nil {
|
||||
if arn, err := buildRDSsubgrpARN(d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).accountid, meta.(*AWSClient).region); err == nil {
|
||||
if err := setTagsRDS(conn, d, arn); err != nil {
|
||||
return err
|
||||
} else {
|
||||
|
@ -227,11 +227,14 @@ func resourceAwsDbSubnetGroupDeleteRefreshFunc(
|
|||
}
|
||||
}
|
||||
|
||||
func buildRDSsubgrpARN(identifier, accountid, region string) (string, error) {
|
||||
func buildRDSsubgrpARN(identifier, partition, accountid, region string) (string, error) {
|
||||
if partition == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS ARN because of missing AWS partition")
|
||||
}
|
||||
if accountid == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS ARN because of missing AWS Account ID")
|
||||
}
|
||||
arn := fmt.Sprintf("arn:aws:rds:%s:%s:subgrp:%s", region, accountid, identifier)
|
||||
arn := fmt.Sprintf("arn:%s:rds:%s:%s:subgrp:%s", partition, region, accountid, identifier)
|
||||
return arn, nil
|
||||
|
||||
}
|
||||
|
|
|
@ -384,7 +384,7 @@ func resourceAwsElasticacheClusterRead(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
// list tags for resource
|
||||
// set tags
|
||||
arn, err := buildECARN(d.Id(), meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
arn, err := buildECARN(d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
if err != nil {
|
||||
log.Printf("[DEBUG] Error building ARN for ElastiCache Cluster, not setting Tags for cluster %s", *c.CacheClusterId)
|
||||
} else {
|
||||
|
@ -409,7 +409,7 @@ func resourceAwsElasticacheClusterRead(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func resourceAwsElasticacheClusterUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).elasticacheconn
|
||||
arn, err := buildECARN(d.Id(), meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
arn, err := buildECARN(d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
if err != nil {
|
||||
log.Printf("[DEBUG] Error building ARN for ElastiCache Cluster, not updating Tags for cluster %s", d.Id())
|
||||
} else {
|
||||
|
@ -661,11 +661,14 @@ func cacheClusterStateRefreshFunc(conn *elasticache.ElastiCache, clusterID, give
|
|||
}
|
||||
}
|
||||
|
||||
func buildECARN(identifier, accountid, region string) (string, error) {
|
||||
func buildECARN(identifier, partition, accountid, region string) (string, error) {
|
||||
if partition == "" {
|
||||
return "", fmt.Errorf("Unable to construct ElastiCache ARN because of missing AWS partition")
|
||||
}
|
||||
if accountid == "" {
|
||||
return "", fmt.Errorf("Unable to construct ElastiCache ARN because of missing AWS Account ID")
|
||||
}
|
||||
arn := fmt.Sprintf("arn:aws:elasticache:%s:%s:cluster:%s", region, accountid, identifier)
|
||||
arn := fmt.Sprintf("arn:%s:elasticache:%s:%s:cluster:%s", partition, region, accountid, identifier)
|
||||
return arn, nil
|
||||
|
||||
}
|
||||
|
|
|
@ -626,6 +626,9 @@ func resourceAwsRDSClusterStateRefreshFunc(
|
|||
}
|
||||
|
||||
func buildRDSClusterARN(identifier, partition, accountid, region string) (string, error) {
|
||||
if partition == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS Cluster ARN because of missing AWS partition")
|
||||
}
|
||||
if accountid == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS Cluster ARN because of missing AWS Account ID")
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ func resourceAwsRDSClusterParameterGroupRead(d *schema.ResourceData, meta interf
|
|||
d.Set("parameter", flattenParameters(describeParametersResp.Parameters))
|
||||
|
||||
paramGroup := describeResp.DBClusterParameterGroups[0]
|
||||
arn, err := buildRDSCPGARN(d.Id(), meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
arn, err := buildRDSCPGARN(d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
if err != nil {
|
||||
name := "<empty>"
|
||||
if paramGroup.DBClusterParameterGroupName != nil && *paramGroup.DBClusterParameterGroupName != "" {
|
||||
|
@ -211,7 +211,7 @@ func resourceAwsRDSClusterParameterGroupUpdate(d *schema.ResourceData, meta inte
|
|||
d.SetPartial("parameter")
|
||||
}
|
||||
|
||||
if arn, err := buildRDSCPGARN(d.Id(), meta.(*AWSClient).accountid, meta.(*AWSClient).region); err == nil {
|
||||
if arn, err := buildRDSCPGARN(d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).accountid, meta.(*AWSClient).region); err == nil {
|
||||
if err := setTagsRDS(rdsconn, d, arn); err != nil {
|
||||
return err
|
||||
} else {
|
||||
|
@ -262,11 +262,14 @@ func resourceAwsRDSClusterParameterGroupDeleteRefreshFunc(
|
|||
}
|
||||
}
|
||||
|
||||
func buildRDSCPGARN(identifier, accountid, region string) (string, error) {
|
||||
func buildRDSCPGARN(identifier, partition, accountid, region string) (string, error) {
|
||||
if partition == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS Cluster ARN because of missing AWS partition")
|
||||
}
|
||||
if accountid == "" {
|
||||
return "", fmt.Errorf("Unable to construct RDS Cluster ARN because of missing AWS Account ID")
|
||||
}
|
||||
arn := fmt.Sprintf("arn:aws:rds:%s:%s:cluster-pg:%s", region, accountid, identifier)
|
||||
arn := fmt.Sprintf("arn:%s:rds:%s:%s:cluster-pg:%s", partition, region, accountid, identifier)
|
||||
return arn, nil
|
||||
|
||||
}
|
||||
|
|
|
@ -526,7 +526,7 @@ func resourceAwsRedshiftClusterUpdate(d *schema.ResourceData, meta interface{})
|
|||
conn := meta.(*AWSClient).redshiftconn
|
||||
d.Partial(true)
|
||||
|
||||
arn, tagErr := buildRedshiftARN(d.Id(), meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
arn, tagErr := buildRedshiftARN(d.Id(), meta.(*AWSClient).partition, meta.(*AWSClient).accountid, meta.(*AWSClient).region)
|
||||
if tagErr != nil {
|
||||
return fmt.Errorf("Error building ARN for Redshift Cluster, not updating Tags for cluster %s", d.Id())
|
||||
} else {
|
||||
|
@ -894,11 +894,14 @@ func validateRedshiftClusterMasterPassword(v interface{}, k string) (ws []string
|
|||
return
|
||||
}
|
||||
|
||||
func buildRedshiftARN(identifier, accountid, region string) (string, error) {
|
||||
func buildRedshiftARN(identifier, partition, accountid, region string) (string, error) {
|
||||
if partition == "" {
|
||||
return "", fmt.Errorf("Unable to construct cluster ARN because of missing AWS partition")
|
||||
}
|
||||
if accountid == "" {
|
||||
return "", fmt.Errorf("Unable to construct cluster ARN because of missing AWS Account ID")
|
||||
}
|
||||
arn := fmt.Sprintf("arn:aws:redshift:%s:%s:cluster:%s", region, accountid, identifier)
|
||||
arn := fmt.Sprintf("arn:%s:redshift:%s:%s:cluster:%s", partition, region, accountid, identifier)
|
||||
return arn, nil
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue