Create an EC2 Instance with Terraform: Difference between revisions
Jump to navigation
Jump to search
Line 38: | Line 38: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Note that even if <code>associate_public_ip_address</code> is explicitly set to " | Note that even if <code>associate_public_ip_address</code> is explicitly set to "true", if the associated subnet has a <code>map_public_ip_on_launch</code> = true, a public IP will be associated anyway. |
Revision as of 21:48, 13 November 2019
External
Internal
Overview
EC2 instances can be created, updated and deleted. Instances also support provisioning.
Configuration
provider "aws" {
profile = "default"
region = "us-west-2"
}
resource "aws_instance" "terraform-test-01" {
ami = "ami-a6faba49dddaecfb7"
instance_type = "m5.4xlarge"
}
Configuration Details
Public IP
If nothing is specified, the instance will get a public IP. To disable allocation of a public address specify:
resource "aws_instance" ... {
...
associate_public_ip_address = false
...
}
Note that even if associate_public_ip_address
is explicitly set to "true", if the associated subnet has a map_public_ip_on_launch
= true, a public IP will be associated anyway.