generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from hashicorp/b-non-synthetic-id-create
Ensure that resource ID is specified when populating Unknown values
- Loading branch information
Showing
3 changed files
with
59 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package ec2_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-provider-awscc/internal/acctest" | ||
) | ||
|
||
func TestAccAWSEC2VPC_CidrBlock(t *testing.T) { | ||
td := acctest.NewTestData(t, "AWS::EC2::VPC", "awscc_ec2_vpc", "test") | ||
resourceName := td.ResourceName | ||
rName := td.RandomName() | ||
cidrBlock := "10.0.0.0/16" | ||
|
||
td.ResourceTest(t, []resource.TestStep{ | ||
{ | ||
Config: testAccAWSEC2VPCCidrBlockConfig(&td, rName, cidrBlock), | ||
Check: resource.ComposeTestCheckFunc( | ||
td.CheckExistsInAWS(), | ||
resource.TestCheckResourceAttr(resourceName, "cidr_block", cidrBlock), | ||
resource.TestCheckResourceAttr(resourceName, "tags.#", "1"), | ||
resource.TestCheckResourceAttr(resourceName, "tags.0.key", "Name"), | ||
resource.TestCheckResourceAttr(resourceName, "tags.0.value", rName), | ||
), | ||
}, | ||
{ | ||
ResourceName: td.ResourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccAWSEC2VPCCidrBlockConfig(td *acctest.TestData, rName, cidrBlock string) string { | ||
return fmt.Sprintf(` | ||
resource %[1]q %[2]q { | ||
cidr_block = %[4]q | ||
tags = [ | ||
{ | ||
key = "Name" | ||
value = %[3]q | ||
} | ||
] | ||
} | ||
`, td.TerraformResourceType, td.ResourceLabel, rName, cidrBlock) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters