Module library

EC2

Terraform module to create AWS EC2 instance(s) resources

Inputs

40 / 83
amioptionalstring

ID of AMI to use for the instance

Defaultnull
ami_ssm_parameteroptionalstring

SSM parameter name for the AMI ID. For Amazon Linux AMI SSM parameters see [reference](https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-public-parameters-ami.html)

Default/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64
associate_public_ip_addressoptionalbool

Whether to associate a public IP address with an instance in a VPC

Defaultnull
availability_zoneoptionalstring

AZ to start the instance in

Defaultnull
capacity_reservation_specificationoptionalobject({ capacity_reservation_preference = optional(string) capacity_reservation…

Describes an instance's Capacity Reservation targeting option

Defaultnull
cpu_creditsoptionalstring

The credit option for CPU usage (unlimited or standard)

Defaultnull
cpu_optionsoptionalobject({ amd_sev_snp = optional(string) core_count = optional(number) nested_vir…

Defines CPU options to apply to the instance at launch time.

Defaultnull
createoptionalbool

Whether to create an instance

Defaulttrue
create_eipoptionalbool

Determines whether a public EIP will be created and associated with the instance.

Defaultfalse
create_iam_instance_profileoptionalbool

Determines whether an IAM instance profile is created or to use an existing IAM instance profile

Defaultfalse
create_security_groupoptionalbool

Determines whether a security group will be created

Defaulttrue
create_spot_instanceoptionalbool

Depicts if the instance is a spot instance

Defaultfalse
disable_api_stopoptionalbool

If true, enables EC2 Instance Stop Protection

Defaultnull
disable_api_terminationoptionalbool

If true, enables EC2 Instance Termination Protection

Defaultnull
ebs_optimizedoptionalbool

If true, the launched EC2 instance will be EBS-optimized

Defaultnull
ebs_volumesoptionalmap(object({ encrypted = optional(bool) final_snapshot = optional(bool) iops = o…

Additional EBS volumes to attach to the instance

Defaultnull
eip_domainoptionalstring

Indicates if this EIP is for use in VPC

Defaultvpc
eip_tagsoptionalmap(string)

A map of additional tags to add to the eip

Default{}
enable_primary_ipv6optionalbool

Whether to assign a primary IPv6 Global Unicast Address (GUA) to the instance when launched in a dual-stack or IPv6-only subnet

Defaultnull
enable_volume_tagsoptionalbool

Whether to enable volume tags (if enabled it conflicts with root_block_device tags)

Defaulttrue
enclave_options_enabledoptionalbool

Whether Nitro Enclaves will be enabled on the instance. Defaults to `false`

Defaultnull
ephemeral_block_deviceoptionalmap(object({ device_name = string no_device = optional(bool) virtual_name = opti…

Customize Ephemeral (also known as Instance Store) volumes on the instance

Defaultnull
force_destroyoptionalbool

Destroys instance even if `disable_api_termination` or `disable_api_stop` is set to true. Once this parameter is set to true, a successful terraform apply run before a destroy is required to update this value in the resource state. Without a successful terraform apply after this parameter is set, th…

Defaultnull
get_password_dataoptionalbool

If true, wait for password data to become available and retrieve it

Defaultnull
hibernationoptionalbool

If true, the launched EC2 instance will support hibernation

Defaultnull
host_idoptionalstring

ID of a dedicated host that the instance will be assigned to. Use when an instance is to be launched on a specific dedicated host

Defaultnull
host_resource_group_arnoptionalstring

ARN of the host resource group in which to launch the instances. If you specify an ARN, omit the `tenancy` parameter or set it to `host`

Defaultnull
iam_instance_profileoptionalstring

IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile

Defaultnull
iam_role_descriptionoptionalstring

Description of the role

Defaultnull
iam_role_nameoptionalstring

Name to use on IAM role created

Defaultnull
iam_role_pathoptionalstring

IAM role path

Defaultnull
iam_role_permissions_boundaryoptionalstring

ARN of the policy that is used to set the permissions boundary for the IAM role

Defaultnull
iam_role_policiesoptionalmap(string)

Policies attached to the IAM role

Default{}
iam_role_tagsoptionalmap(string)

A map of additional tags to add to the IAM role/profile created

Default{}
iam_role_use_name_prefixoptionalbool

Determines whether the IAM role name (`iam_role_name` or `name`) is used as a prefix

Defaulttrue
ignore_ami_changesoptionalbool

Whether changes to the AMI ID changes should be ignored by Terraform. Note - changing this value will result in the replacement of the instance

Defaultfalse
instance_initiated_shutdown_behavioroptionalstring

Shutdown behavior for the instance. Amazon defaults this to stop for EBS-backed instances and terminate for instance-store instances. Cannot be set on instance-store instance

Defaultnull
instance_market_optionsoptionalobject({ market_type = optional(string) spot_options = optional(object({ instanc…

The market (purchasing) option for the instance. If set, overrides the `create_spot_instance` variable

Defaultnull
instance_tagsoptionalmap(string)

Additional tags for the instance

Default{}
instance_typeoptionalstring

The type of instance to start

Defaultt3.micro

All 83 are optional — the module deploys with none of them set. Showing 40, so the site stays a static download — the remaining 43 are in the source.

Outputs

30
ami

AMI ID that was used to create the instance

arn

The ARN of the instance

availability_zone

The availability zone of the created instance

capacity_reservation_specification

Capacity reservation specification of the instance

ebs_block_device

EBS block device information

ebs_volumes

Map of EBS volumes created and their attributes

ephemeral_block_device

Ephemeral block device information

iam_instance_profile_arn

ARN assigned by AWS to the instance profile

iam_instance_profile_id

Instance profile's ID

iam_instance_profile_unique

Stable and unique string identifying the IAM instance profile

iam_role_arn

The Amazon Resource Name (ARN) specifying the IAM role

iam_role_name

The name of the IAM role

iam_role_unique_id

Stable and unique string identifying the IAM role

id

The ID of the instance

instance_state

The state of the instance

ipv6_addresses

The IPv6 address assigned to the instance, if applicable

outpost_arn

The ARN of the Outpost the instance is assigned to

password_data

Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if `get_password_data` is true

primary_network_interface_id

The ID of the instance's primary network interface

private_dns

The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC

private_ip

The private IP address assigned to the instance

public_dns

The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC

public_ip

The public IP address assigned to the instance, if applicable.

root_block_device

Root block device information

security_group_arn

Amazon Resource Name (ARN) of the security group

security_group_id

ID of the security group

spot_bid_status

The current bid status of the Spot Instance Request

spot_instance_id

The Instance ID (if any) that is currently fulfilling the Spot Instance request

spot_request_state

The current request state of the Spot Instance Request

tags_all

A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block

What the agent wires into the next module. An edge on the architecture diagram is one of these consumed by something else.