Skip to content

Latest commit

 

History

History

session-manager

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

EC2 instance w/ private network access via Session Manager

The configuration in this directory creates an EC2 instance not connected to the Internet that can be accessed using Session Manager through VPC Endpoints.

This example outputs instance id, ARN, state, and tags.

Usage

To run this example you need to execute:

$ terraform init
$ terraform plan
$ terraform apply

You can verify that SSM is setup correctly by connecting to the instance. The example output provides the AWS CLI command to connect to the instance under the output ssm_connect_command which will look like:

aws ssm start-session --target <INSTANCE-ID> --region <REGION>

You will need to have the Session Manager plugin for the AWS CLI installed to execute the command. Instructions for installing can be found here.

Note that this example may create resources which can cost money. Run terraform destroy when you don't need these resources.

Requirements

Name Version
terraform >= 1.0
aws >= 4.66

Providers

Name Version
aws >= 4.66

Modules

Name Source Version
ec2 ../../ n/a
security_group_instance terraform-aws-modules/security-group/aws ~> 5.0
vpc terraform-aws-modules/vpc/aws ~> 5.0
vpc_endpoints terraform-aws-modules/vpc/aws//modules/vpc-endpoints ~> 5.0

Resources

Name Type
aws_availability_zones.available data source

Inputs

No inputs.

Outputs

Name Description
ec2_arn The ARN of the instance
ec2_capacity_reservation_specification Capacity reservation specification of the instance
ec2_ebs_block_device EBS block device information
ec2_ephemeral_block_device Ephemeral block device information
ec2_iam_instance_profile_arn ARN assigned by AWS to the instance profile
ec2_iam_instance_profile_id Instance profile's ID
ec2_iam_instance_profile_unique Stable and unique string identifying the IAM instance profile
ec2_iam_role_arn The Amazon Resource Name (ARN) specifying the IAM role
ec2_iam_role_name The name of the IAM role
ec2_iam_role_unique_id Stable and unique string identifying the IAM role
ec2_id The ID of the instance
ec2_instance_state The state of the instance. One of: pending, running, shutting-down, terminated, stopping, stopped
ec2_primary_network_interface_id The ID of the instance's primary network interface
ec2_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
ec2_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
ec2_public_ip The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use public_ip as this field will change after the EIP is attached
ec2_root_block_device Root block device information
ec2_tags_all A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block
ssm_connect_command The AWS CLI command to connect to the instance using Session Manager