Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/stable-website' into master2-w…
Browse files Browse the repository at this point in the history
…ith-emr-fleet
  • Loading branch information
jocgir committed Mar 16, 2019
2 parents 475411e + 3cf16f8 commit 8beb502
Show file tree
Hide file tree
Showing 469 changed files with 89,203 additions and 18,861 deletions.
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
## 2.2.0 (March 15, 2019)

FEATURES:

* **New Resource:** `aws_globalaccelerator_listener` ([#7003](https://github.com/terraform-providers/terraform-provider-aws/issues/7003))
* **New Resource:** `aws_guardduty_invite_accepter` ([#4610](https://github.com/terraform-providers/terraform-provider-aws/issues/4610))
* **New Resource:** `aws_route53_resolver_rule` ([#7799](https://github.com/terraform-providers/terraform-provider-aws/issues/7799))
* **New Resource:** `aws_route53_resolver_rule_association` ([#7799](https://github.com/terraform-providers/terraform-provider-aws/issues/7799))

ENHANCEMENTS:

* data-source/aws_eip: Add `private_dns` and `public_dns` attributes ([#7349](https://github.com/terraform-providers/terraform-provider-aws/issues/7349))
* resource/aws_backup_vault: Support `tags` updates ([#7933](https://github.com/terraform-providers/terraform-provider-aws/issues/7933))
* resource/aws_dx_bgp_peer: Add `aws_device` and `bgp_peer_id` attributes ([#7131](https://github.com/terraform-providers/terraform-provider-aws/issues/7131))
* resource/aws_dx_connection: Add `aws_device` and `has_logical_redundancy` attributes ([#7131](https://github.com/terraform-providers/terraform-provider-aws/issues/7131))
* resource/aws_dx_hosted_private_virtual_interface: Add `aws_device` attribute ([#7131](https://github.com/terraform-providers/terraform-provider-aws/issues/7131))
* resource/aws_dx_hosted_public_virtual_interface: Add `aws_device` attribute ([#7131](https://github.com/terraform-providers/terraform-provider-aws/issues/7131))
* resource/aws_dx_lag: Add `has_logical_redundancy` attribute ([#7131](https://github.com/terraform-providers/terraform-provider-aws/issues/7131))
* resource/aws_dx_private_virtual_interface: Add `aws_device` attribute ([#7131](https://github.com/terraform-providers/terraform-provider-aws/issues/7131))
* resource/aws_dx_public_virtual_interface: Add `aws_device` attribute ([#7131](https://github.com/terraform-providers/terraform-provider-aws/issues/7131))
* resource/aws_eip: Add `private_dns` and `public_dns` attributes ([#7349](https://github.com/terraform-providers/terraform-provider-aws/issues/7349))
* resource/aws_glue_crawler: Add `arn` attribute ([#7948](https://github.com/terraform-providers/terraform-provider-aws/issues/7948))
* resource/aws_ssm_patch_baseline: Support resource import ([#7838](https://github.com/terraform-providers/terraform-provider-aws/issues/7838))

BUG FIXES:

* resource/aws_cloudfront_distribution: Ensure retain_on_delete disables the CloudFront Distribution before exiting ([#7875](https://github.com/terraform-providers/terraform-provider-aws/issues/7875))
* resource/aws_cloudwatch_log_metric_filter: Serialize create, update, and delete operations on the same CloudWatch Log Group to prevent `OperationAbortedException` errors ([#7880](https://github.com/terraform-providers/terraform-provider-aws/issues/7880))
* resource/aws_codebuild_webhook: Only pass BranchFilter configuration if non-empty ([#7841](https://github.com/terraform-providers/terraform-provider-aws/issues/7841))
* resource/aws_ec2_transit_gateway_vpc_attachment: Prevent errors with Resource Access Manager shared EC2 Transit Gateways ([#7513](https://github.com/terraform-providers/terraform-provider-aws/issues/7513))
* resource/aws_ecr_repository_policy: Properly read `policy` into the Terraform state ([#7853](https://github.com/terraform-providers/terraform-provider-aws/issues/7853))
* resource/aws_iam_role_policy_attachment: Prevent `NoSuchEntity` errors from race conditions ([#7855](https://github.com/terraform-providers/terraform-provider-aws/issues/7855))
* resource/aws_kms_alias: Prevent state removal of resource immediately after creation due to eventual consistency ([#7891](https://github.com/terraform-providers/terraform-provider-aws/issues/7891))
* resource/aws_s3_bucket: Prevent empty `replication_configuration` `rules` `filter` crash ([#7887](https://github.com/terraform-providers/terraform-provider-aws/issues/7887))
* resource/aws_s3_bucket: Continue supporting empty string (`""`) `bucket` argument ([#7881](https://github.com/terraform-providers/terraform-provider-aws/issues/7881))
* resource/aws_s3_bucket: Prevent `NoSuchBucket` errors when putting lifecycle configuration on resource creation ([#7930](https://github.com/terraform-providers/terraform-provider-aws/issues/7930))
* resource/aws_ses_domain_mail_from: Prevent crash with deleted SES Domain Identity ([#7883](https://github.com/terraform-providers/terraform-provider-aws/issues/7883))

## 2.1.0 (March 07, 2019)

FEATURES:
Expand Down
2 changes: 1 addition & 1 deletion aws/awserr.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func isAWSErr(err error, code string, message string) bool {

func retryOnAwsCode(code string, f func() (interface{}, error)) (interface{}, error) {
var resp interface{}
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
err := resource.Retry(2*time.Minute, func() *resource.RetryError {
var err error
resp, err = f()
if err != nil {
Expand Down
32 changes: 31 additions & 1 deletion aws/data_source_aws_eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package aws
import (
"fmt"
"log"
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
Expand Down Expand Up @@ -44,11 +45,19 @@ func dataSourceAwsEip() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"private_dns": {
Type: schema.TypeString,
Computed: true,
},
"public_ip": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"public_dns": {
Type: schema.TypeString,
Computed: true,
},
"public_ipv4_pool": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -86,7 +95,6 @@ func dataSourceAwsEipRead(d *schema.ResourceData, meta interface{}) error {
req.Filters = nil
}

log.Printf("[DEBUG] Reading EIP: %s", req)
resp, err := conn.DescribeAddresses(req)
if err != nil {
return fmt.Errorf("error describing EC2 Address: %s", err)
Expand All @@ -112,8 +120,30 @@ func dataSourceAwsEipRead(d *schema.ResourceData, meta interface{}) error {
d.Set("instance_id", eip.InstanceId)
d.Set("network_interface_id", eip.NetworkInterfaceId)
d.Set("network_interface_owner_id", eip.NetworkInterfaceOwnerId)

region := *conn.Config.Region

d.Set("private_ip", eip.PrivateIpAddress)
if eip.PrivateIpAddress != nil {
dashIP := strings.Replace(*eip.PrivateIpAddress, ".", "-", -1)

if region == "us-east-1" {
d.Set("private_dns", fmt.Sprintf("ip-%s.ec2.internal", dashIP))
} else {
d.Set("private_dns", fmt.Sprintf("ip-%s.%s.compute.internal", dashIP, region))
}
}

d.Set("public_ip", eip.PublicIp)
if eip.PublicIp != nil {
dashIP := strings.Replace(*eip.PublicIp, ".", "-", -1)

if region == "us-east-1" {
d.Set("public_dns", fmt.Sprintf("ec2-%s.compute-1.amazonaws.com", dashIP))
} else {
d.Set("public_dns", fmt.Sprintf("ec2-%s.%s.compute.amazonaws.com", dashIP, region))
}
}
d.Set("public_ipv4_pool", eip.PublicIpv4Pool)
d.Set("tags", tagsToMap(eip.Tags))

Expand Down
6 changes: 6 additions & 0 deletions aws/data_source_aws_eip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestAccDataSourceAwsEip_Filter(t *testing.T) {
Config: testAccDataSourceAwsEipConfigFilter(rName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "id", resourceName, "id"),
resource.TestCheckResourceAttrPair(dataSourceName, "public_dns", resourceName, "public_dns"),
resource.TestCheckResourceAttrPair(dataSourceName, "public_ip", resourceName, "public_ip"),
),
},
Expand All @@ -40,6 +41,7 @@ func TestAccDataSourceAwsEip_Id(t *testing.T) {
Config: testAccDataSourceAwsEipConfigId,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "id", resourceName, "id"),
resource.TestCheckResourceAttrPair(dataSourceName, "public_dns", resourceName, "public_dns"),
resource.TestCheckResourceAttrPair(dataSourceName, "public_ip", resourceName, "public_ip"),
),
},
Expand All @@ -61,6 +63,7 @@ func TestAccDataSourceAwsEip_PublicIP_EC2Classic(t *testing.T) {
Config: testAccDataSourceAwsEipConfigPublicIpEc2Classic,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "id", resourceName, "id"),
resource.TestCheckResourceAttrPair(dataSourceName, "public_dns", resourceName, "public_dns"),
resource.TestCheckResourceAttrPair(dataSourceName, "public_ip", resourceName, "public_ip"),
),
},
Expand All @@ -80,6 +83,7 @@ func TestAccDataSourceAwsEip_PublicIP_VPC(t *testing.T) {
Config: testAccDataSourceAwsEipConfigPublicIpVpc,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "id", resourceName, "id"),
resource.TestCheckResourceAttrPair(dataSourceName, "public_dns", resourceName, "public_dns"),
resource.TestCheckResourceAttrPair(dataSourceName, "public_ip", resourceName, "public_ip"),
resource.TestCheckResourceAttrPair(dataSourceName, "domain", resourceName, "domain"),
),
Expand All @@ -101,6 +105,7 @@ func TestAccDataSourceAwsEip_Tags(t *testing.T) {
Config: testAccDataSourceAwsEipConfigTags(rName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "id", resourceName, "id"),
resource.TestCheckResourceAttrPair(dataSourceName, "public_dns", resourceName, "public_dns"),
resource.TestCheckResourceAttrPair(dataSourceName, "public_ip", resourceName, "public_ip"),
),
},
Expand All @@ -121,6 +126,7 @@ func TestAccDataSourceAwsEip_NetworkInterface(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "id", resourceName, "id"),
resource.TestCheckResourceAttrPair(dataSourceName, "network_interface_id", resourceName, "network_interface"),
resource.TestCheckResourceAttrPair(dataSourceName, "private_dns", resourceName, "private_dns"),
resource.TestCheckResourceAttrPair(dataSourceName, "private_ip", resourceName, "private_ip"),
resource.TestCheckResourceAttrPair(dataSourceName, "domain", resourceName, "domain"),
),
Expand Down
4 changes: 4 additions & 0 deletions aws/diff_suppress_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,9 @@ func suppressAutoscalingGroupAvailabilityZoneDiffs(k, old, new string, d *schema
}

func suppressRoute53ZoneNameWithTrailingDot(k, old, new string, d *schema.ResourceData) bool {
// "." is different from "".
if old == "." || new == "." {
return old == new
}
return strings.TrimSuffix(old, ".") == strings.TrimSuffix(new, ".")
}
56 changes: 56 additions & 0 deletions aws/diff_suppress_funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,59 @@ func TestSuppressEquivalentTypeStringBoolean(t *testing.T) {
}
}
}

func TestSuppressRoute53ZoneNameWithTrailingDot(t *testing.T) {
testCases := []struct {
old string
new string
equivalent bool
}{
{
old: "example.com",
new: "example.com",
equivalent: true,
},
{
old: "example.com.",
new: "example.com.",
equivalent: true,
},
{
old: "example.com.",
new: "example.com",
equivalent: true,
},
{
old: "example.com",
new: "example.com.",
equivalent: true,
},
{
old: ".",
new: "",
equivalent: false,
},
{
old: "",
new: ".",
equivalent: false,
},
{
old: ".",
new: ".",
equivalent: true,
},
}

for i, tc := range testCases {
value := suppressRoute53ZoneNameWithTrailingDot("test_property", tc.old, tc.new, nil)

if tc.equivalent && !value {
t.Fatalf("expected test case %d to be equivalent", i)
}

if !tc.equivalent && value {
t.Fatalf("expected test case %d to not be equivalent", i)
}
}
}
4 changes: 4 additions & 0 deletions aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ func Provider() terraform.ResourceProvider {
"aws_glacier_vault": resourceAwsGlacierVault(),
"aws_glacier_vault_lock": resourceAwsGlacierVaultLock(),
"aws_globalaccelerator_accelerator": resourceAwsGlobalAcceleratorAccelerator(),
"aws_globalaccelerator_listener": resourceAwsGlobalAcceleratorListener(),
"aws_glue_catalog_database": resourceAwsGlueCatalogDatabase(),
"aws_glue_catalog_table": resourceAwsGlueCatalogTable(),
"aws_glue_classifier": resourceAwsGlueClassifier(),
Expand All @@ -477,6 +478,7 @@ func Provider() terraform.ResourceProvider {
"aws_glue_security_configuration": resourceAwsGlueSecurityConfiguration(),
"aws_glue_trigger": resourceAwsGlueTrigger(),
"aws_guardduty_detector": resourceAwsGuardDutyDetector(),
"aws_guardduty_invite_accepter": resourceAwsGuardDutyInviteAccepter(),
"aws_guardduty_ipset": resourceAwsGuardDutyIpset(),
"aws_guardduty_member": resourceAwsGuardDutyMember(),
"aws_guardduty_threatintelset": resourceAwsGuardDutyThreatintelset(),
Expand Down Expand Up @@ -607,6 +609,8 @@ func Provider() terraform.ResourceProvider {
"aws_route53_zone": resourceAwsRoute53Zone(),
"aws_route53_health_check": resourceAwsRoute53HealthCheck(),
"aws_route53_resolver_endpoint": resourceAwsRoute53ResolverEndpoint(),
"aws_route53_resolver_rule_association": resourceAwsRoute53ResolverRuleAssociation(),
"aws_route53_resolver_rule": resourceAwsRoute53ResolverRule(),
"aws_route": resourceAwsRoute(),
"aws_route_table": resourceAwsRouteTable(),
"aws_default_route_table": resourceAwsDefaultRouteTable(),
Expand Down
21 changes: 21 additions & 0 deletions aws/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ func testAccGetPartition() string {
return "aws"
}

func testAccAlternateAccountPreCheck(t *testing.T) {
if os.Getenv("AWS_ALTERNATE_PROFILE") == "" && os.Getenv("AWS_ALTERNATE_ACCESS_KEY_ID") == "" {
t.Fatal("AWS_ALTERNATE_ACCESS_KEY_ID or AWS_ALTERNATE_PROFILE must be set for acceptance tests")
}

if os.Getenv("AWS_ALTERNATE_ACCESS_KEY_ID") != "" && os.Getenv("AWS_ALTERNATE_SECRET_ACCESS_KEY") == "" {
t.Fatal("AWS_ALTERNATE_SECRET_ACCESS_KEY must be set for acceptance tests")
}
}

func testAccEC2ClassicPreCheck(t *testing.T) {
client := testAccProvider.Meta().(*AWSClient)
platforms := client.supportedplatforms
Expand Down Expand Up @@ -231,6 +241,17 @@ func testAccOrganizationsAccountPreCheck(t *testing.T) {
t.Skip("skipping tests; this AWS account must not be an existing member of an AWS Organization")
}

func testAccAlternateAccountProviderConfig() string {
return fmt.Sprintf(`
provider "aws" {
access_key = %[1]q
alias = "alternate"
profile = %[2]q
secret_key = %[3]q
}
`, os.Getenv("AWS_ALTERNATE_ACCESS_KEY_ID"), os.Getenv("AWS_ALTERNATE_PROFILE"), os.Getenv("AWS_ALTERNATE_SECRET_ACCESS_KEY"))
}

func testAccAwsRegionProviderFunc(region string, providers *[]*schema.Provider) func() *schema.Provider {
return func() *schema.Provider {
if region == "" {
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_api_gateway_authorizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ EOF
resource "aws_lambda_function" "authorizer" {
filename = "test-fixtures/lambdatest.zip"
source_code_hash = "${base64sha256(file("test-fixtures/lambdatest.zip"))}"
source_code_hash = "${filebase64sha256("test-fixtures/lambdatest.zip")}"
function_name = "%s"
role = "${aws_iam_role.iam_for_lambda.arn}"
handler = "exports.example"
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_api_gateway_usage_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ resource "aws_api_gateway_deployment" "test" {
}
resource "aws_api_gateway_deployment" "foo" {
depends_on = ["aws_api_gateway_integration.test"]
depends_on = ["aws_api_gateway_deployment.test", "aws_api_gateway_integration.test"]
rest_api_id = "${aws_api_gateway_rest_api.test.id}"
stage_name = "foo"
Expand Down
Loading

0 comments on commit 8beb502

Please sign in to comment.