|
| 1 | +# EC2 instance w/ private network access via Session Manager |
| 2 | + |
| 3 | +The configuration in this directory creates an EC2 instance not connected to the Internet that can be accessed using Session Manager through VPC Endpoints. |
| 4 | + |
| 5 | +This example outputs instance id, ARN, state, and tags. |
| 6 | + |
| 7 | +## Usage |
| 8 | + |
| 9 | +To run this example you need to execute: |
| 10 | + |
| 11 | +```bash |
| 12 | +$ terraform init |
| 13 | +$ terraform plan |
| 14 | +$ terraform apply |
| 15 | +``` |
| 16 | + |
| 17 | +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: |
| 18 | + |
| 19 | +```bash |
| 20 | +aws ssm start-session --target <INSTANCE-ID> --region <REGION> |
| 21 | +``` |
| 22 | + |
| 23 | +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](https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html). |
| 24 | + |
| 25 | +Note that this example may create resources which can cost money. Run `terraform destroy` when you don't need these resources. |
| 26 | + |
| 27 | +<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 28 | +## Requirements |
| 29 | + |
| 30 | +| Name | Version | |
| 31 | +|------|---------| |
| 32 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 | |
| 33 | +| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.66 | |
| 34 | + |
| 35 | +## Providers |
| 36 | + |
| 37 | +| Name | Version | |
| 38 | +|------|---------| |
| 39 | +| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.66 | |
| 40 | + |
| 41 | +## Modules |
| 42 | + |
| 43 | +| Name | Source | Version | |
| 44 | +|------|--------|---------| |
| 45 | +| <a name="module_ec2"></a> [ec2](#module\_ec2) | ../../ | n/a | |
| 46 | +| <a name="module_security_group_instance"></a> [security\_group\_instance](#module\_security\_group\_instance) | terraform-aws-modules/security-group/aws | ~> 5.0 | |
| 47 | +| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 | |
| 48 | +| <a name="module_vpc_endpoints"></a> [vpc\_endpoints](#module\_vpc\_endpoints) | terraform-aws-modules/vpc/aws//modules/vpc-endpoints | ~> 5.0 | |
| 49 | + |
| 50 | +## Resources |
| 51 | + |
| 52 | +| Name | Type | |
| 53 | +|------|------| |
| 54 | +| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source | |
| 55 | + |
| 56 | +## Inputs |
| 57 | + |
| 58 | +No inputs. |
| 59 | + |
| 60 | +## Outputs |
| 61 | + |
| 62 | +| Name | Description | |
| 63 | +|------|-------------| |
| 64 | +| <a name="output_ec2_arn"></a> [ec2\_arn](#output\_ec2\_arn) | The ARN of the instance | |
| 65 | +| <a name="output_ec2_capacity_reservation_specification"></a> [ec2\_capacity\_reservation\_specification](#output\_ec2\_capacity\_reservation\_specification) | Capacity reservation specification of the instance | |
| 66 | +| <a name="output_ec2_ebs_block_device"></a> [ec2\_ebs\_block\_device](#output\_ec2\_ebs\_block\_device) | EBS block device information | |
| 67 | +| <a name="output_ec2_ephemeral_block_device"></a> [ec2\_ephemeral\_block\_device](#output\_ec2\_ephemeral\_block\_device) | Ephemeral block device information | |
| 68 | +| <a name="output_ec2_iam_instance_profile_arn"></a> [ec2\_iam\_instance\_profile\_arn](#output\_ec2\_iam\_instance\_profile\_arn) | ARN assigned by AWS to the instance profile | |
| 69 | +| <a name="output_ec2_iam_instance_profile_id"></a> [ec2\_iam\_instance\_profile\_id](#output\_ec2\_iam\_instance\_profile\_id) | Instance profile's ID | |
| 70 | +| <a name="output_ec2_iam_instance_profile_unique"></a> [ec2\_iam\_instance\_profile\_unique](#output\_ec2\_iam\_instance\_profile\_unique) | Stable and unique string identifying the IAM instance profile | |
| 71 | +| <a name="output_ec2_iam_role_arn"></a> [ec2\_iam\_role\_arn](#output\_ec2\_iam\_role\_arn) | The Amazon Resource Name (ARN) specifying the IAM role | |
| 72 | +| <a name="output_ec2_iam_role_name"></a> [ec2\_iam\_role\_name](#output\_ec2\_iam\_role\_name) | The name of the IAM role | |
| 73 | +| <a name="output_ec2_iam_role_unique_id"></a> [ec2\_iam\_role\_unique\_id](#output\_ec2\_iam\_role\_unique\_id) | Stable and unique string identifying the IAM role | |
| 74 | +| <a name="output_ec2_id"></a> [ec2\_id](#output\_ec2\_id) | The ID of the instance | |
| 75 | +| <a name="output_ec2_instance_state"></a> [ec2\_instance\_state](#output\_ec2\_instance\_state) | The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped` | |
| 76 | +| <a name="output_ec2_primary_network_interface_id"></a> [ec2\_primary\_network\_interface\_id](#output\_ec2\_primary\_network\_interface\_id) | The ID of the instance's primary network interface | |
| 77 | +| <a name="output_ec2_private_dns"></a> [ec2\_private\_dns](#output\_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 | |
| 78 | +| <a name="output_ec2_public_dns"></a> [ec2\_public\_dns](#output\_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 | |
| 79 | +| <a name="output_ec2_public_ip"></a> [ec2\_public\_ip](#output\_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 | |
| 80 | +| <a name="output_ec2_root_block_device"></a> [ec2\_root\_block\_device](#output\_ec2\_root\_block\_device) | Root block device information | |
| 81 | +| <a name="output_ec2_tags_all"></a> [ec2\_tags\_all](#output\_ec2\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block | |
| 82 | +| <a name="output_ssm_connect_command"></a> [ssm\_connect\_command](#output\_ssm\_connect\_command) | The AWS CLI command to connect to the instance using Session Manager | |
| 83 | +<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
0 commit comments