Skip to content

opsd-io/terraform-module-aws-instance

Repository files navigation

OPSd

Meet OPSd. The unique and effortless way of managing cloud infrastructure.

terraform-module-aws-instance

Introduction

What does the module provide?

Usage

module "module_name" {
  source  = "github.com/opsd-io/terraform-module-aws-instance"

  name          = "my-host"
  ami_id        = data.aws_ami.debian11.id
  instance_type = "t2.micro"
  subnet_id     = module.network.public_subnet_groups["public1"]["a"].id
  key_name      = aws_key_pair.me.key_name
}

IMPORTANT: Make sure not to pin to master because there may be breaking changes between releases.

Requirements

Name Version
terraform >= 1.3.1
aws ~> 5.0

Providers

Name Version
aws ~> 5.0

Modules

No modules.

Resources

Name Type
aws_instance.main resource
aws_route53_record.private_cnames resource
aws_route53_record.private_ip resource
aws_route53_record.public_cnames resource
aws_route53_record.public_ip resource
aws_ec2_instance_type.main data source

Inputs

Name Description Type Default Required
ami_id AMI to use for the instance. Overrides the AMI specified in the Launch Template. string null no
associate_public_ip_address Whether to associate a public IP address with an instance in a VPC. Overrides subnet setting. bool null no
common_tags A map of tags to assign to every resource in this module. map(string) {} no
ebs_optimized If true, the launched EC2 instance will be EBS-optimized. bool null no
enable_resource_name_dns_a_record Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Overrides subnet setting. bool null no
enable_resource_name_dns_aaaa_record Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Overrides subnet setting. bool null no
hostname_type Type of hostname for Amazon EC2 instances. Valid values: ip-name and resource-name. Overrides subnet setting. string null no
iam_instance_profile IAM Instance Profile to launch the instance with. string null no
instance_type Instance type to use for the instance. Overrides the instance type specified in the Launch Template. string null no
key_name Key name of the Key Pair to use for the instance. string null no
monitoring If true, the launched EC2 instance will have detailed monitoring enabled. bool false no
name The 'Name' tag of instance. string n/a yes
private_zone_id The ID of the hosted zone to contain private IP record. string null no
private_zone_record_cnames The CNAMEs of the private zone record. list(string) [] no
private_zone_record_name The name of the private zone record. Fallback to instance name. string null no
private_zone_record_ttl The TTL of the private records. number 600 no
public_zone_id The ID of the hosted zone to contain public IP record, if any. string null no
public_zone_record_cnames The CNAMEs of the public zone record. list(string) [] no
public_zone_record_name The name of the public zone record. Fallback to instance name. string null no
public_zone_record_ttl The TTL of the public records. number 600 no
root_iops Amount of provisioned IOPS. Only valid for root_volume_type of io1, io2 or gp3. Defaults to AMI setting. number null no
root_volume_encryption Whether to enable root volume encryption. Defaults to AMI setting. bool null no
root_volume_size Size of the root volume in gibibytes (GiB). Defaults to AMI setting. number null no
root_volume_type Type of root volume. Defaults to AMI setting. string null no
security_group_ids List of security group IDs to associate with. list(string) [] no
source_dest_check Controls if traffic is routed to the instance when the destination address does not match the instance. bool true no
subnet_id VPC Subnet ID to launch in. string n/a yes
user_data User data to provide when launching the instance. string null no
user_data_base64 User data to provide when launching the instance. string null no

Outputs

Name Description
arn The ARN of the instance.
id The ID of the instance.
private_ip The private IP of the instance.
public_ip The public IP of the instance.
root_volume_id The ID of the root volume.

Examples of usage

Do you want to see how the module works? See all the usage examples.

Related modules

The list of related modules (if present).

Contributing

If you are interested in contributing to the project, see see our guide.

Support

If you have a problem with the module or want to propose a new feature, you can report it via the project's (Github) issue tracker.

If you want to discuss something in person, you can join our community on Slack.

License

Apache License 2.0