Creating and configuring your Cloud9 instance
We will use the following Terraform code to create a Cloud9 instance, allow the user defined within the myuser_arn local to use it, and connect it to the subnet defined in subnet_id. As we have defined the connection type as CONNECT_SSM, this subnet can be private as long as it has connectivity to the AWS SSM API, either through a private endpoint or a NAT gateway:
data "aws_region" "current" {}
locals {
myuser_arn = "arn:aws:sts::123:myuser"
}
resource "aws_cloud9_environment_ec2" "k8sdev" {
name = "k8sdev"
instance_type = "t3.medium"
connection_type = "CONNECT_SSM"
description = "cloud9 K8s development environment"
subnet_id = "subnet-123"
owner_arn = local.myuser_arn
}
data "aws_instance" "cloud9_instance" {
filter {
...