Skip to content

Commit

Permalink
Merge pull request #9 from terraform-providers/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
DrFaust92 authored Nov 5, 2019
2 parents e5b7302 + f39af7f commit 199b669
Show file tree
Hide file tree
Showing 18 changed files with 404 additions and 568 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/pull_requests.yml

This file was deleted.

20 changes: 13 additions & 7 deletions .hashibot.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ behavior "regexp_issue_labeler_v2" "service_labels" {
"aws_cloudsearch_",
],
"service/cloudtrail" = [
"aws_cloudtrail_",
"aws_cloudtrail",
],
"service/cloudwatch" = [
"aws_cloudwatch_([^e]|e[^v]|ev[^e]|eve[^n]|even[^t]|event[^_]|[^l]|l[^o]|lo[^g]|log[^_])",
Expand Down Expand Up @@ -536,7 +536,9 @@ behavior "pull_request_path_labeler" "service_labels" {
]
"service/apigateway" = [
"**/*_api_gateway_[^v][^2][^_]*",
"**/api_gateway_[^v][^2][^_]*"
"**/*_api_gateway_vpc_link*",
"**/api_gateway_[^v][^2][^_]*",
"**/api_gateway_vpc_link*"
]
"service/apigatewayv2" = [
"**/*_api_gateway_v2_*",
Expand Down Expand Up @@ -567,7 +569,7 @@ behavior "pull_request_path_labeler" "service_labels" {
"**/appsync_*"
]
"service/athena" = [
"service/athena",
"**/*_athena_*",
"**/athena_*"
]
"service/autoscaling" = [
Expand Down Expand Up @@ -617,8 +619,8 @@ behavior "pull_request_path_labeler" "service_labels" {
"**/cloudsearch_*"
]
"service/cloudtrail" = [
"**/*_cloudtrail_*",
"**/cloudtrail_*"
"**/*_cloudtrail*",
"**/cloudtrail*"
]
"service/cloudwatch" = [
"**/*_cloudwatch_dashboard*",
Expand Down Expand Up @@ -977,6 +979,10 @@ behavior "pull_request_path_labeler" "service_labels" {
"**/*_pricing_*",
"**/pricing_*"
]
"service/qldb" = [
"**/*_qldb_*",
"**/qldb_*"
]
"service/quicksight" = [
"**/*_quicksight_*",
"**/quicksight_*"
Expand Down Expand Up @@ -1020,8 +1026,8 @@ behavior "pull_request_path_labeler" "service_labels" {
"**/route53_domains_*"
]
"service/route53resolver" = [
"**/*_route53resolver_*",
"**/route53resolver_*"
"**/*_route53_resolver_*",
"**/route53_resolver_*"
]
"service/s3" = [
"**/*_s3_bucket*",
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ENHANCEMENTS:
* data-source/aws_db_instance: Add `tags` attribute [GH-10550]
* data-source/aws_vpc_endpoint: Add `filter` and `tags` arguments [GH-10503]
* provider: Add `ignore_tag_prefixes` and `ignore_tags` arguments (in public preview, see note above) [GH-10418]
* resource/aws_acmpca_certificate_authority: Support tagging on creation [GH-10736]
* resource/aws_api_gateway_api_key: Add `tags` argument and `arn` attribute [GH-10568]
* resource/aws_api_gateway_client_certificate: Add `tags` argument and `arn` attribute [GH-10569]
* resource/aws_api_gateway_domain_name: Add `tags` argument and `arn` attribute [GH-10567]
Expand Down
5 changes: 3 additions & 2 deletions aws/data_source_aws_ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)

func dataSourceAwsAmi() *schema.Resource {
Expand Down Expand Up @@ -290,8 +291,8 @@ func amiDescriptionAttributes(d *schema.ResourceData, image *ec2.Image) error {
if err := d.Set("state_reason", amiStateReason(image.StateReason)); err != nil {
return err
}
if err := d.Set("tags", tagsToMap(image.Tags)); err != nil {
return err
if err := d.Set("tags", keyvaluetags.Ec2KeyValueTags(image.Tags).IgnoreAws().Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
}
return nil
}
Expand Down
143 changes: 73 additions & 70 deletions aws/data_source_aws_ami_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,117 +10,120 @@ import (
)

func TestAccAWSAmiDataSource_natInstance(t *testing.T) {
resourceName := "data.aws_ami.nat_ami"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckAwsAmiDataSourceConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAmiDataSourceID("data.aws_ami.nat_ami"),
testAccCheckAwsAmiDataSourceID(resourceName),
// Check attributes. Some attributes are tough to test - any not contained here should not be considered
// stable and should not be used in interpolation. Exception to block_device_mappings which should both
// show up consistently and break if certain references are not available. However modification of the
// snapshot ID which is bound to happen on the NAT AMIs will cause testing to break consistently, so
// deep inspection is not included, simply the count is checked.
// Tags and product codes may need more testing, but I'm having a hard time finding images with
// these attributes set.
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "architecture", "x86_64"),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "block_device_mappings.#", "1"),
resource.TestMatchResourceAttr("data.aws_ami.nat_ami", "creation_date", regexp.MustCompile("^20[0-9]{2}-")),
resource.TestMatchResourceAttr("data.aws_ami.nat_ami", "description", regexp.MustCompile("^Amazon Linux AMI")),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "hypervisor", "xen"),
resource.TestMatchResourceAttr("data.aws_ami.nat_ami", "image_id", regexp.MustCompile("^ami-")),
resource.TestMatchResourceAttr("data.aws_ami.nat_ami", "image_location", regexp.MustCompile("^amazon/")),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "image_owner_alias", "amazon"),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "image_type", "machine"),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "most_recent", "true"),
resource.TestMatchResourceAttr("data.aws_ami.nat_ami", "name", regexp.MustCompile("^amzn-ami-vpc-nat")),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "owner_id", "137112412989"),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "public", "true"),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "product_codes.#", "0"),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "root_device_name", "/dev/xvda"),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "root_device_type", "ebs"),
resource.TestMatchResourceAttr("data.aws_ami.nat_ami", "root_snapshot_id", regexp.MustCompile("^snap-")),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "sriov_net_support", "simple"),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "state", "available"),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "state_reason.code", "UNSET"),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "state_reason.message", "UNSET"),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "tags.%", "0"),
resource.TestCheckResourceAttr("data.aws_ami.nat_ami", "virtualization_type", "hvm"),
resource.TestCheckResourceAttr(resourceName, "architecture", "x86_64"),
resource.TestCheckResourceAttr(resourceName, "block_device_mappings.#", "1"),
resource.TestMatchResourceAttr(resourceName, "creation_date", regexp.MustCompile("^20[0-9]{2}-")),
resource.TestMatchResourceAttr(resourceName, "description", regexp.MustCompile("^Amazon Linux AMI")),
resource.TestCheckResourceAttr(resourceName, "hypervisor", "xen"),
resource.TestMatchResourceAttr(resourceName, "image_id", regexp.MustCompile("^ami-")),
resource.TestMatchResourceAttr(resourceName, "image_location", regexp.MustCompile("^amazon/")),
resource.TestCheckResourceAttr(resourceName, "image_owner_alias", "amazon"),
resource.TestCheckResourceAttr(resourceName, "image_type", "machine"),
resource.TestCheckResourceAttr(resourceName, "most_recent", "true"),
resource.TestMatchResourceAttr(resourceName, "name", regexp.MustCompile("^amzn-ami-vpc-nat")),
resource.TestCheckResourceAttr(resourceName, "owner_id", "137112412989"),
resource.TestCheckResourceAttr(resourceName, "public", "true"),
resource.TestCheckResourceAttr(resourceName, "product_codes.#", "0"),
resource.TestCheckResourceAttr(resourceName, "root_device_name", "/dev/xvda"),
resource.TestCheckResourceAttr(resourceName, "root_device_type", "ebs"),
resource.TestMatchResourceAttr(resourceName, "root_snapshot_id", regexp.MustCompile("^snap-")),
resource.TestCheckResourceAttr(resourceName, "sriov_net_support", "simple"),
resource.TestCheckResourceAttr(resourceName, "state", "available"),
resource.TestCheckResourceAttr(resourceName, "state_reason.code", "UNSET"),
resource.TestCheckResourceAttr(resourceName, "state_reason.message", "UNSET"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "virtualization_type", "hvm"),
),
},
},
})
}
func TestAccAWSAmiDataSource_windowsInstance(t *testing.T) {
resourceName := "data.aws_ami.windows_ami"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckAwsAmiDataSourceWindowsConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAmiDataSourceID("data.aws_ami.windows_ami"),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "architecture", "x86_64"),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "block_device_mappings.#", "27"),
resource.TestMatchResourceAttr("data.aws_ami.windows_ami", "creation_date", regexp.MustCompile("^20[0-9]{2}-")),
resource.TestMatchResourceAttr("data.aws_ami.windows_ami", "description", regexp.MustCompile("^Microsoft Windows Server")),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "hypervisor", "xen"),
resource.TestMatchResourceAttr("data.aws_ami.windows_ami", "image_id", regexp.MustCompile("^ami-")),
resource.TestMatchResourceAttr("data.aws_ami.windows_ami", "image_location", regexp.MustCompile("^amazon/")),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "image_owner_alias", "amazon"),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "image_type", "machine"),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "most_recent", "true"),
resource.TestMatchResourceAttr("data.aws_ami.windows_ami", "name", regexp.MustCompile("^Windows_Server-2012-R2")),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "owner_id", "801119661308"),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "platform", "windows"),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "public", "true"),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "product_codes.#", "0"),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "root_device_name", "/dev/sda1"),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "root_device_type", "ebs"),
resource.TestMatchResourceAttr("data.aws_ami.windows_ami", "root_snapshot_id", regexp.MustCompile("^snap-")),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "sriov_net_support", "simple"),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "state", "available"),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "state_reason.code", "UNSET"),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "state_reason.message", "UNSET"),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "tags.%", "0"),
resource.TestCheckResourceAttr("data.aws_ami.windows_ami", "virtualization_type", "hvm"),
testAccCheckAwsAmiDataSourceID(resourceName),
resource.TestCheckResourceAttr(resourceName, "architecture", "x86_64"),
resource.TestCheckResourceAttr(resourceName, "block_device_mappings.#", "27"),
resource.TestMatchResourceAttr(resourceName, "creation_date", regexp.MustCompile("^20[0-9]{2}-")),
resource.TestMatchResourceAttr(resourceName, "description", regexp.MustCompile("^Microsoft Windows Server")),
resource.TestCheckResourceAttr(resourceName, "hypervisor", "xen"),
resource.TestMatchResourceAttr(resourceName, "image_id", regexp.MustCompile("^ami-")),
resource.TestMatchResourceAttr(resourceName, "image_location", regexp.MustCompile("^amazon/")),
resource.TestCheckResourceAttr(resourceName, "image_owner_alias", "amazon"),
resource.TestCheckResourceAttr(resourceName, "image_type", "machine"),
resource.TestCheckResourceAttr(resourceName, "most_recent", "true"),
resource.TestMatchResourceAttr(resourceName, "name", regexp.MustCompile("^Windows_Server-2012-R2")),
resource.TestCheckResourceAttr(resourceName, "owner_id", "801119661308"),
resource.TestCheckResourceAttr(resourceName, "platform", "windows"),
resource.TestCheckResourceAttr(resourceName, "public", "true"),
resource.TestCheckResourceAttr(resourceName, "product_codes.#", "0"),
resource.TestCheckResourceAttr(resourceName, "root_device_name", "/dev/sda1"),
resource.TestCheckResourceAttr(resourceName, "root_device_type", "ebs"),
resource.TestMatchResourceAttr(resourceName, "root_snapshot_id", regexp.MustCompile("^snap-")),
resource.TestCheckResourceAttr(resourceName, "sriov_net_support", "simple"),
resource.TestCheckResourceAttr(resourceName, "state", "available"),
resource.TestCheckResourceAttr(resourceName, "state_reason.code", "UNSET"),
resource.TestCheckResourceAttr(resourceName, "state_reason.message", "UNSET"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "virtualization_type", "hvm"),
),
},
},
})
}

func TestAccAWSAmiDataSource_instanceStore(t *testing.T) {
resourceName := "data.aws_ami.instance_store_ami"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckAwsAmiDataSourceInstanceStoreConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAmiDataSourceID("data.aws_ami.instance_store_ami"),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "architecture", "x86_64"),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "block_device_mappings.#", "0"),
resource.TestMatchResourceAttr("data.aws_ami.instance_store_ami", "creation_date", regexp.MustCompile("^20[0-9]{2}-")),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "hypervisor", "xen"),
resource.TestMatchResourceAttr("data.aws_ami.instance_store_ami", "image_id", regexp.MustCompile("^ami-")),
resource.TestMatchResourceAttr("data.aws_ami.instance_store_ami", "image_location", regexp.MustCompile("ubuntu-trusty-14.04-amd64-server")),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "image_type", "machine"),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "most_recent", "true"),
resource.TestMatchResourceAttr("data.aws_ami.instance_store_ami", "name", regexp.MustCompile("^ubuntu/images/hvm-instance/ubuntu-trusty-14.04-amd64-server")),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "owner_id", "099720109477"),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "public", "true"),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "product_codes.#", "0"),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "root_device_type", "instance-store"),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "root_snapshot_id", ""),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "sriov_net_support", "simple"),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "state", "available"),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "state_reason.code", "UNSET"),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "state_reason.message", "UNSET"),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "tags.%", "0"),
resource.TestCheckResourceAttr("data.aws_ami.instance_store_ami", "virtualization_type", "hvm"),
testAccCheckAwsAmiDataSourceID(resourceName),
resource.TestCheckResourceAttr(resourceName, "architecture", "x86_64"),
resource.TestCheckResourceAttr(resourceName, "block_device_mappings.#", "0"),
resource.TestMatchResourceAttr(resourceName, "creation_date", regexp.MustCompile("^20[0-9]{2}-")),
resource.TestCheckResourceAttr(resourceName, "hypervisor", "xen"),
resource.TestMatchResourceAttr(resourceName, "image_id", regexp.MustCompile("^ami-")),
resource.TestMatchResourceAttr(resourceName, "image_location", regexp.MustCompile("ubuntu-trusty-14.04-amd64-server")),
resource.TestCheckResourceAttr(resourceName, "image_type", "machine"),
resource.TestCheckResourceAttr(resourceName, "most_recent", "true"),
resource.TestMatchResourceAttr(resourceName, "name", regexp.MustCompile("^ubuntu/images/hvm-instance/ubuntu-trusty-14.04-amd64-server")),
resource.TestCheckResourceAttr(resourceName, "owner_id", "099720109477"),
resource.TestCheckResourceAttr(resourceName, "public", "true"),
resource.TestCheckResourceAttr(resourceName, "product_codes.#", "0"),
resource.TestCheckResourceAttr(resourceName, "root_device_type", "instance-store"),
resource.TestCheckResourceAttr(resourceName, "root_snapshot_id", ""),
resource.TestCheckResourceAttr(resourceName, "sriov_net_support", "simple"),
resource.TestCheckResourceAttr(resourceName, "state", "available"),
resource.TestCheckResourceAttr(resourceName, "state_reason.code", "UNSET"),
resource.TestCheckResourceAttr(resourceName, "state_reason.message", "UNSET"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "virtualization_type", "hvm"),
),
},
},
Expand Down
10 changes: 10 additions & 0 deletions aws/internal/keyvaluetags/generators/listtags/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var serviceNames = []string{
"cloudhsmv2",
"cloudwatch",
"cloudwatchevents",
"cloudwatchlogs",
"codecommit",
"codedeploy",
"codepipeline",
Expand Down Expand Up @@ -79,6 +80,7 @@ var serviceNames = []string{
"securityhub",
"sfn",
"sns",
"sqs",
"ssm",
"storagegateway",
"swf",
Expand Down Expand Up @@ -192,6 +194,8 @@ func ServiceListTagsFunction(serviceName string) string {
return "ListTags"
case "cloudhsmv2":
return "ListTags"
case "cloudwatchlogs":
return "ListTagsLogGroup"
case "dax":
return "ListTags"
case "dynamodb":
Expand Down Expand Up @@ -220,6 +224,8 @@ func ServiceListTagsFunction(serviceName string) string {
return "GetTags"
case "sagemaker":
return "ListTags"
case "sqs":
return "ListQueueTags"
case "workspaces":
return "DescribeTags"
default:
Expand All @@ -242,6 +248,8 @@ func ServiceListTagsInputIdentifierField(serviceName string) string {
return "ResourceARN"
case "cloudwatchevents":
return "ResourceARN"
case "cloudwatchlogs":
return "LogGroupName"
case "dax":
return "ResourceName"
case "devicefarm":
Expand Down Expand Up @@ -282,6 +290,8 @@ func ServiceListTagsInputIdentifierField(serviceName string) string {
return "ResourceName"
case "resourcegroups":
return "Arn"
case "sqs":
return "QueueUrl"
case "ssm":
return "ResourceId"
case "storagegateway":
Expand Down
Loading

0 comments on commit 199b669

Please sign in to comment.