Skip to content

Commit

Permalink
Merge pull request #13 from terraform-providers/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
DrFaust92 authored Nov 15, 2019
2 parents 45a3c82 + 12b40de commit 44defd1
Show file tree
Hide file tree
Showing 68 changed files with 1,625 additions and 1,824 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,22 @@

ENHANCEMENTS:

* resource/aws_api_gateway_rest_api: Add `tags` argument and `arn` attribute [GH-10581]
* resource/aws_db_instance: Add `ca_cert_identifier` argument [GH-10490]
* resource/aws_dlm_lifecycle_policy: Add `tags` argument and `arn` attribute [GH-10864]
* resource/aws_efs_file_system: Add `AFTER_7_DAYS` as a valid `lifecycle_policy` configuratio block `transition_to_ia` argument value [GH-10825]
* resource/aws_glue_crawler: Add `tags` argument [GH-10805]
* resource/aws_s3_bucket_inventory: Add `IntelligentTieringAccessTier` as valid value for `optional_fields` argument [GH-10746]
* resource/aws_waf_geo_match_set: Support resource import and add `arn` attribute [GH-10480]
* resource/aws_waf_regex_match_set: Support resource import and add `arn` attribute [GH-10481]
* resource/aws_waf_regex_pattern_set: Support resource import and add `arn` attribute [GH-10482]
* resource/aws_waf_size_constraint_set: Support resource import and add `arn` attribute [GH-10484]
* resource/aws_waf_xss_match_set: Support resource import and add `arn` attribute [GH-10485]
* resource/aws_wafregional_rate_based_rule: Add `tags` argument and `arn` attribute [GH-10897]
* resource/aws_wafregional_rule_group: Add `tags` argument and `arn` attribute [GH-10896]
* resource/aws_wafregional_rule: Add `tags` argument and `arn` attribute [GH-10895]
* resource/aws_wafregional_web_acl: Add `tags` argument [GH-10889]
* resource/aws_wafregional_web_acl_association: Support resource import [GH-10538]

BUG FIXES:

Expand Down
3 changes: 2 additions & 1 deletion aws/data_source_aws_secretsmanager_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/aws/aws-sdk-go/service/secretsmanager"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/structure"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)

func dataSourceAwsSecretsManagerSecret() *schema.Resource {
Expand Down Expand Up @@ -131,7 +132,7 @@ func dataSourceAwsSecretsManagerSecretRead(d *schema.ResourceData, meta interfac
return fmt.Errorf("error setting rotation_rules: %s", err)
}

if err := d.Set("tags", tagsToMapSecretsManager(output.Tags)); err != nil {
if err := d.Set("tags", keyvaluetags.SecretsmanagerKeyValueTags(output.Tags).IgnoreAws().Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}

Expand Down
14 changes: 13 additions & 1 deletion aws/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func testAccMatchResourceAttrRegionalARN(resourceName, attributeName, arnService
}
}

// testAccMatchResourceAttrRegionalARN ensures the Terraform state regexp matches a formatted ARN with region and no account id
// testAccMatchResourceAttrRegionalARNNoAccount ensures the Terraform state regexp matches a formatted ARN with region but without account ID
func testAccMatchResourceAttrRegionalARNNoAccount(resourceName, attributeName, arnService string, arnResourceRegexp *regexp.Regexp) resource.TestCheckFunc {
return func(s *terraform.State) error {
arnRegexp := arn.ARN{
Expand Down Expand Up @@ -161,6 +161,18 @@ func testAccCheckResourceAttrGlobalARN(resourceName, attributeName, arnService,
}
}

// testAccCheckResourceAttrGlobalARNNoAccount ensures the Terraform state exactly matches a formatted ARN without region or account ID
func testAccCheckResourceAttrGlobalARNNoAccount(resourceName, attributeName, arnService, arnResource string) resource.TestCheckFunc {
return func(s *terraform.State) error {
attributeValue := arn.ARN{
Partition: testAccGetPartition(),
Resource: arnResource,
Service: arnService,
}.String()
return resource.TestCheckResourceAttr(resourceName, attributeName, attributeValue)(s)
}
}

// testAccMatchResourceAttrGlobalARN ensures the Terraform state regexp matches a formatted ARN without region
func testAccMatchResourceAttrGlobalARN(resourceName, attributeName, arnService string, arnResourceRegexp *regexp.Regexp) resource.TestCheckFunc {
return func(s *terraform.State) error {
Expand Down
39 changes: 36 additions & 3 deletions aws/resource_aws_api_gateway_rest_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/structure"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)

func resourceAwsApiGatewayRestApi() *schema.Resource {
Expand All @@ -38,7 +39,11 @@ func resourceAwsApiGatewayRestApi() *schema.Resource {
"api_key_source": {
Type: schema.TypeString,
Optional: true,
Default: "HEADER",
ValidateFunc: validation.StringInSlice([]string{
apigateway.ApiKeySourceTypeAuthorizer,
apigateway.ApiKeySourceTypeHeader,
}, true),
Default: apigateway.ApiKeySourceTypeHeader,
},

"policy": {
Expand Down Expand Up @@ -105,6 +110,11 @@ func resourceAwsApiGatewayRestApi() *schema.Resource {
},
},
},
"arn": {
Type: schema.TypeString,
Computed: true,
},
"tags": tagsSchema(),
},
}
}
Expand Down Expand Up @@ -135,6 +145,10 @@ func resourceAwsApiGatewayRestApiCreate(d *schema.ResourceData, meta interface{}
params.Policy = aws.String(v.(string))
}

if v, ok := d.GetOk("tags"); ok {
params.Tags = keyvaluetags.New(v.(map[string]interface{})).IgnoreAws().ApigatewayTags()
}

binaryMediaTypes, binaryMediaTypesOk := d.GetOk("binary_media_types")
if binaryMediaTypesOk {
params.BinaryMediaTypes = expandStringList(binaryMediaTypes.([]interface{}))
Expand Down Expand Up @@ -221,14 +235,14 @@ func resourceAwsApiGatewayRestApiRead(d *schema.ResourceData, meta interface{})

d.Set("binary_media_types", api.BinaryMediaTypes)

arn := arn.ARN{
execution_arn := arn.ARN{
Partition: meta.(*AWSClient).partition,
Service: "execute-api",
Region: meta.(*AWSClient).region,
AccountID: meta.(*AWSClient).accountid,
Resource: d.Id(),
}.String()
d.Set("execution_arn", arn)
d.Set("execution_arn", execution_arn)

if api.MinimumCompressionSize == nil {
d.Set("minimum_compression_size", -1)
Expand All @@ -243,6 +257,18 @@ func resourceAwsApiGatewayRestApiRead(d *schema.ResourceData, meta interface{})
return fmt.Errorf("error setting endpoint_configuration: %s", err)
}

if err := d.Set("tags", keyvaluetags.ApigatewayKeyValueTags(api.Tags).IgnoreAws().Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}

rest_api_arn := arn.ARN{
Partition: meta.(*AWSClient).partition,
Service: "apigateway",
Region: meta.(*AWSClient).region,
Resource: fmt.Sprintf("/restapis/%s", d.Id()),
}.String()
d.Set("arn", rest_api_arn)

return nil
}

Expand Down Expand Up @@ -342,6 +368,13 @@ func resourceAwsApiGatewayRestApiUpdate(d *schema.ResourceData, meta interface{}
conn := meta.(*AWSClient).apigateway
log.Printf("[DEBUG] Updating API Gateway %s", d.Id())

if d.HasChange("tags") {
o, n := d.GetChange("tags")
if err := keyvaluetags.ApigatewayUpdateTags(conn, d.Get("arn").(string), o, n); err != nil {
return fmt.Errorf("error updating tags: %s", err)
}
}

if d.HasChange("body") {
if body, ok := d.GetOk("body"); ok {
log.Printf("[DEBUG] Updating API Gateway from OpenAPI spec: %s", d.Id())
Expand Down
Loading

0 comments on commit 44defd1

Please sign in to comment.