Skip to main content

EC2 Instance

Deploy an EC2 Instance, including server hardening, IAM role, EIP, EBS Volume, and CloudWatch metrics, logs, and alerts.

View on GitHub

Reference

  • alarms_sns_topic_arn The ARNs of SNS topics where CloudWatch alarms (e.g., for CPU, memory, and disk space usage) should send notifications.
  • ami The AMI to run on the EC2 instance. This should be built from the Packer template under ec2-instance.json. One of var.ami or ami_filters is required. Set to null if looking up the ami with filters.
  • ami_filters Properties on the AMI that can be used to lookup a prebuilt AMI for use with the EC2 instance. You can build the AMI using the Packer template ec2-instance.json. Only used if var.ami is null. One of var.ami or ami_filters is required. Set to null if passing the ami ID directly.
  • attach_eip Determines if an Elastic IP (EIP) will be created for this instance.
  • base_domain_name_tags Tags to use to filter the Route 53 Hosted Zones that might match the hosted zone's name (use if you have multiple public hosted zones with the same name)
  • default_user The default OS user for the EC2 instance AMI. For AWS Ubuntu AMIs, which is what the Packer template in ec2-instance.json uses, the default OS user is 'ubuntu'.
  • dns_ttl DNS Time To Live in seconds.
  • ebs_volumes The EBS volumes to attach to the instance. This must be a map of key/value pairs.
  • enable_cloudwatch_alarms Set to true to enable several basic CloudWatch alarms around CPU usage, memory usage, and disk space usage. If set to true, make sure to specify SNS topics to send notifications to using alarms_sns_topic_arn.
  • enable_fail2ban Enable fail2ban to block brute force log in attempts. Defaults to true.
  • enable_ip_lockdown Enable ip-lockdown to block access to the instance metadata. Defaults to true.
  • external_account_ssh_grunt_role_arn If you are using ssh-grunt and your IAM users / groups are defined in a separate AWS account, you can use this variable to specify the ARN of an IAM role that ssh-grunt can assume to retrieve IAM group and public SSH key info from that account. To omit this variable, set it to an empty string (do NOT use null, or Terraform will complain).
  • instance_type The type of instance to run for the EC2 instance
  • keypair_name The name of a Key Pair that can be used to SSH to this instance. This instance may have ssh-grunt installed. The preferred way to do SSH access is with your own IAM user name and SSH key. This Key Pair is only as a fallback.
  • name The name of the EC2 instance and the other resources created by these templates
  • ssh_grunt_iam_group If you are using ssh-grunt, this is the name of the IAM group from which users will be allowed to SSH to this EC2 instance. To omit this variable, set it to an empty string (do NOT use null, or Terraform will complain).
  • ssh_grunt_iam_group_sudo If you are using ssh-grunt, this is the name of the IAM group from which users will be allowed to SSH to this EC2 instance. To omit this variable, set it to an empty string (do NOT use null, or Terraform will complain).
  • subnet_id The ID of the subnet in which to deploy the EC2 instance. Must be a subnet in vpc_id.
  • tags A map of tags to apply to the EC2 instance and the S3 Buckets. The key is the tag name and the value is the tag value.
  • tenancy The tenancy of this instance. Must be one of: default, dedicated, or host.
  • vpc_id The ID of the VPC in which to deploy the EC2 instance.