Assigns a static IP to the Cloud9 EC2 environment and outputs the public IP address.

Terraform Template

data "aws_instance" "cloud9_instance" {

  filter {
    name = "tag:aws:cloud9:environment"
    values = [aws_cloud9_environment_ec2.example.id]
  }
}

resource "aws_cloud9_environment_ec2" "example" {
  instance_type = "t2.micro"
}

resource "aws_eip" "cloud9_eip" {
  domain = "vpc"
  instance = data.aws_instance.cloud9_instance.id
}

output "cloud9_public_ip" {
  value = aws_eip.cloud9_eip.public_ip
}