Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ubuntu 22.04 to Cloud9 ec2 options #33662

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/33662.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_cloud9_environment_ec2: Add `ubuntu-22.04-x86_64` and `resolve:ssm:/aws/service/cloud9/amis/ubuntu-22.04-x86_64` as valid values for `image_id`
```
2 changes: 2 additions & 0 deletions internal/service/cloud9/environment_ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ func ResourceEnvironmentEC2() *schema.Resource {
"amazonlinux-1-x86_64",
"amazonlinux-2-x86_64",
"ubuntu-18.04-x86_64",
"ubuntu-22.04-x86_64",
"resolve:ssm:/aws/service/cloud9/amis/amazonlinux-1-x86_64",
"resolve:ssm:/aws/service/cloud9/amis/amazonlinux-2-x86_64",
"resolve:ssm:/aws/service/cloud9/amis/ubuntu-18.04-x86_64",
"resolve:ssm:/aws/service/cloud9/amis/ubuntu-22.04-x86_64",
}, false),
},
"instance_type": {
Expand Down
53 changes: 18 additions & 35 deletions internal/service/cloud9/environment_ec2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func TestAccCloud9EnvironmentEC2_allFields(t *testing.T) {
name2 := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
description1 := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
description2 := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
imageID := "ubuntu-22.04-x86_64"
resourceName := "aws_cloud9_environment_ec2.test"

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -72,17 +73,17 @@ func TestAccCloud9EnvironmentEC2_allFields(t *testing.T) {
CheckDestroy: testAccCheckEnvironmentEC2Destroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccEnvironmentEC2Config_allFields(rName, name1, description1),
Config: testAccEnvironmentEC2Config_allFields(rName, name1, description1, imageID),
Check: resource.ComposeTestCheckFunc(
testAccCheckEnvironmentEC2Exists(ctx, resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, "automatic_stop_time_minutes", "60"),
resource.TestCheckResourceAttr(resourceName, "connection_type", "CONNECT_SSH"),
resource.TestCheckResourceAttr(resourceName, "description", description1),
resource.TestCheckResourceAttr(resourceName, "image_id", "amazonlinux-2-x86_64"),
resource.TestCheckResourceAttr(resourceName, "image_id", imageID),
resource.TestCheckResourceAttr(resourceName, "instance_type", "t2.micro"),
resource.TestCheckResourceAttr(resourceName, "name", name1),
resource.TestCheckResourceAttrPair(resourceName, "owner_arn", "aws_iam_user.test", "arn"),
resource.TestCheckResourceAttrPair(resourceName, "subnet_id", "aws_subnet.test", "id"),
resource.TestCheckResourceAttrPair(resourceName, "subnet_id", "aws_subnet.test.0", "id"),
resource.TestCheckResourceAttr(resourceName, "type", "ec2"),
),
},
Expand All @@ -93,7 +94,7 @@ func TestAccCloud9EnvironmentEC2_allFields(t *testing.T) {
ImportStateVerifyIgnore: []string{"automatic_stop_time_minutes", "image_id", "instance_type", "subnet_id"},
},
{
Config: testAccEnvironmentEC2Config_allFields(rName, name2, description2),
Config: testAccEnvironmentEC2Config_allFields(rName, name2, description2, imageID),
Check: resource.ComposeTestCheckFunc(
testAccCheckEnvironmentEC2Exists(ctx, resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, "description", description2),
Expand Down Expand Up @@ -228,26 +229,8 @@ func testAccCheckEnvironmentEC2Destroy(ctx context.Context) resource.TestCheckFu
}
}

func testAccEnvironmentEC2BaseConfig(rName string) string {
return acctest.ConfigCompose(acctest.ConfigAvailableAZsNoOptInDefaultExclude(), fmt.Sprintf(`
resource "aws_vpc" "test" {
cidr_block = "10.0.0.0/16"

tags = {
Name = %[1]q
}
}

resource "aws_subnet" "test" {
availability_zone = data.aws_availability_zones.available.names[0]
cidr_block = "10.0.0.0/24"
vpc_id = aws_vpc.test.id

tags = {
Name = %[1]q
}
}

func testAccEnvironmentEC2Config_base(rName string) string {
return acctest.ConfigCompose(acctest.ConfigVPCWithSubnets(rName, 1), fmt.Sprintf(`
resource "aws_internet_gateway" "test" {
vpc_id = aws_vpc.test.id

Expand All @@ -265,40 +248,40 @@ resource "aws_route" "test" {
}

func testAccEnvironmentEC2Config_basic(rName string) string {
return acctest.ConfigCompose(testAccEnvironmentEC2BaseConfig(rName), fmt.Sprintf(`
return acctest.ConfigCompose(testAccEnvironmentEC2Config_base(rName), fmt.Sprintf(`
resource "aws_cloud9_environment_ec2" "test" {
instance_type = "t2.micro"
name = %[1]q
subnet_id = aws_subnet.test.id
subnet_id = aws_subnet.test[0].id
}
`, rName))
}

func testAccEnvironmentEC2Config_allFields(rName, name, description string) string {
return acctest.ConfigCompose(testAccEnvironmentEC2BaseConfig(rName), fmt.Sprintf(`
func testAccEnvironmentEC2Config_allFields(rName, name, description, imageID string) string {
return acctest.ConfigCompose(testAccEnvironmentEC2Config_base(rName), fmt.Sprintf(`
resource "aws_cloud9_environment_ec2" "test" {
automatic_stop_time_minutes = 60
description = %[2]q
instance_type = "t2.micro"
name = %[1]q
owner_arn = aws_iam_user.test.arn
subnet_id = aws_subnet.test.id
subnet_id = aws_subnet.test[0].id
connection_type = "CONNECT_SSH"
image_id = "amazonlinux-2-x86_64"
image_id = %[4]q
}

resource "aws_iam_user" "test" {
name = %[3]q
}
`, name, description, rName))
`, name, description, rName, imageID))
}

func testAccEnvironmentEC2Config_tags1(rName, tagKey1, tagValue1 string) string {
return acctest.ConfigCompose(testAccEnvironmentEC2BaseConfig(rName), fmt.Sprintf(`
return acctest.ConfigCompose(testAccEnvironmentEC2Config_base(rName), fmt.Sprintf(`
resource "aws_cloud9_environment_ec2" "test" {
instance_type = "t2.micro"
name = %[1]q
subnet_id = aws_subnet.test.id
subnet_id = aws_subnet.test[0].id

tags = {
%[2]q = %[3]q
Expand All @@ -308,11 +291,11 @@ resource "aws_cloud9_environment_ec2" "test" {
}

func testAccEnvironmentEC2Config_tags2(rName, tagKey1, tagValue1, tagKey2, tagValue2 string) string {
return acctest.ConfigCompose(testAccEnvironmentEC2BaseConfig(rName), fmt.Sprintf(`
return acctest.ConfigCompose(testAccEnvironmentEC2Config_base(rName), fmt.Sprintf(`
resource "aws_cloud9_environment_ec2" "test" {
instance_type = "t2.micro"
name = %[1]q
subnet_id = aws_subnet.test.id
subnet_id = aws_subnet.test[0].id

tags = {
%[2]q = %[3]q
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/cloud9_environment_ec2.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ This resource supports the following arguments:
* `amazonlinux-1-x86_64`
* `amazonlinux-2-x86_64`
* `ubuntu-18.04-x86_64`
* `ubuntu-22.04-x86_64`
* `resolve:ssm:/aws/service/cloud9/amis/amazonlinux-1-x86_64`
* `resolve:ssm:/aws/service/cloud9/amis/amazonlinux-2-x86_64`
* `resolve:ssm:/aws/service/cloud9/amis/ubuntu-18.04-x86_64`
* `resolve:ssm:/aws/service/cloud9/amis/ubuntu-22.04-x86_64`

* `owner_arn` - (Optional) The ARN of the environment owner. This can be ARN of any AWS IAM principal. Defaults to the environment's creator.
* `subnet_id` - (Optional) The ID of the subnet in Amazon VPC that AWS Cloud9 will use to communicate with the Amazon EC2 instance.
* `tags` - (Optional) Key-value map of resource tags. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.
Expand Down