Skip to content

Commit

Permalink
resource/aws_launch_template: Add acceptance test for placement host_…
Browse files Browse the repository at this point in the history
…resource_group_arn and CHANGELOG for #15785

Output from acceptance testing:

```
--- PASS: TestAccAWSLaunchTemplate_associateCarrierIPAddress (113.88s)
--- PASS: TestAccAWSLaunchTemplate_associatePublicIPAddress (112.32s)
--- PASS: TestAccAWSLaunchTemplate_basic (26.20s)
--- PASS: TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS (62.22s)
--- PASS: TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS_DeleteOnTermination (80.25s)
--- PASS: TestAccAWSLaunchTemplate_BlockDeviceMappings_EBS_Gp3 (67.53s)
--- PASS: TestAccAWSLaunchTemplate_capacityReservation_preference (30.12s)
--- PASS: TestAccAWSLaunchTemplate_capacityReservation_target (32.17s)
--- PASS: TestAccAWSLaunchTemplate_cpuOptions (20.02s)
--- PASS: TestAccAWSLaunchTemplate_creditSpecification_nonBurstable (23.74s)
--- PASS: TestAccAWSLaunchTemplate_creditSpecification_t2 (27.49s)
--- PASS: TestAccAWSLaunchTemplate_creditSpecification_t3 (26.61s)
--- PASS: TestAccAWSLaunchTemplate_data (31.18s)
--- PASS: TestAccAWSLaunchTemplate_defaultVersion (66.15s)
--- PASS: TestAccAWSLaunchTemplate_description (49.72s)
--- PASS: TestAccAWSLaunchTemplate_disappears (21.60s)
--- PASS: TestAccAWSLaunchTemplate_EbsOptimized (90.05s)
--- PASS: TestAccAWSLaunchTemplate_ElasticInferenceAccelerator (48.44s)
--- PASS: TestAccAWSLaunchTemplate_enclaveOptions (70.97s)
--- PASS: TestAccAWSLaunchTemplate_hibernation (70.97s)
--- PASS: TestAccAWSLaunchTemplate_IamInstanceProfile_EmptyConfigurationBlock (23.89s)
--- PASS: TestAccAWSLaunchTemplate_instanceMarketOptions (81.70s)
--- PASS: TestAccAWSLaunchTemplate_licenseSpecification (31.41s)
--- PASS: TestAccAWSLaunchTemplate_metadataOptions (30.40s)
--- PASS: TestAccAWSLaunchTemplate_networkInterface (71.60s)
--- PASS: TestAccAWSLaunchTemplate_networkInterface_ipv6AddressCount (32.24s)
--- PASS: TestAccAWSLaunchTemplate_networkInterface_ipv6Addresses (31.31s)
--- PASS: TestAccAWSLaunchTemplate_networkInterfaceAddresses (71.44s)
--- PASS: TestAccAWSLaunchTemplate_NetworkInterfaces_DeleteOnTermination (85.38s)
--- PASS: TestAccAWSLaunchTemplate_Placement_HostResourceGroupArn (33.94s)
--- PASS: TestAccAWSLaunchTemplate_placement_partitionNum (51.75s)
--- PASS: TestAccAWSLaunchTemplate_tags (49.81s)
--- PASS: TestAccAWSLaunchTemplate_update (80.24s)
--- PASS: TestAccAWSLaunchTemplate_updateDefaultVersion (89.33s)

--- PASS: TestAccAWSLaunchTemplateDataSource_associateCarrierIPAddress (52.34s)
--- PASS: TestAccAWSLaunchTemplateDataSource_associatePublicIPAddress (75.31s)
--- PASS: TestAccAWSLaunchTemplateDataSource_basic (28.98s)
--- PASS: TestAccAWSLaunchTemplateDataSource_enclaveOptions (29.01s)
--- PASS: TestAccAWSLaunchTemplateDataSource_filter_basic (27.33s)
--- PASS: TestAccAWSLaunchTemplateDataSource_filter_tags (26.50s)
--- PASS: TestAccAWSLaunchTemplateDataSource_id_basic (30.08s)
--- PASS: TestAccAWSLaunchTemplateDataSource_metadataOptions (27.67s)
--- PASS: TestAccAWSLaunchTemplateDataSource_networkInterfaces_deleteOnTermination (61.06s)
--- PASS: TestAccAWSLaunchTemplateDataSource_NonExistent (3.34s)
```
  • Loading branch information
bflad committed Apr 28, 2021
1 parent 6c5471c commit d835a03
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changelog/15785.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
data-source/aws_launch_template: Add `placement` `host_resource_group_arn` attribute
```

```release-note:enhancement
resource/aws_launch_template: Add `placement` `host_resource_group_arn` argument
```
55 changes: 55 additions & 0 deletions aws/resource_aws_launch_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,33 @@ func TestAccAWSLaunchTemplate_associateCarrierIPAddress(t *testing.T) {
})
}

func TestAccAWSLaunchTemplate_Placement_HostResourceGroupArn(t *testing.T) {
var template ec2.LaunchTemplate
resourceName := "aws_launch_template.test"
rName := acctest.RandomWithPrefix("tf-acc-test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, ec2.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSLaunchTemplateDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSLaunchTemplateConfigPlacementHostResourceGroupArn(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSLaunchTemplateExists(resourceName, &template),
resource.TestCheckResourceAttrPair(resourceName, "placement.0.host_resource_group_arn", "aws_resourcegroups_group.test", "arn"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSLaunchTemplate_placement_partitionNum(t *testing.T) {
var template ec2.LaunchTemplate
resourceName := "aws_launch_template.test"
Expand Down Expand Up @@ -1746,6 +1773,34 @@ resource "aws_launch_template" "test" {
`, rName, partNum)
}

func testAccAWSLaunchTemplateConfigPlacementHostResourceGroupArn(rName string) string {
return fmt.Sprintf(`
resource "aws_resourcegroups_group" "test" {
name = %[1]q
resource_query {
query = jsonencode({
ResourceTypeFilters = ["AWS::EC2::Instance"]
TagFilters = [
{
Key = "Stage"
Values = ["Test"]
},
]
})
}
}
resource "aws_launch_template" "test" {
name = %[1]q
placement {
host_resource_group_arn = aws_resourcegroups_group.test.arn
}
}
`, rName)
}

func testAccAWSLaunchTemplateConfig_networkInterfaceAddresses(rName string) string {
return fmt.Sprintf(`
resource "aws_vpc" "test" {
Expand Down

0 comments on commit d835a03

Please sign in to comment.