Skip to content

Fix AWS EC2 tags format from block to map and update README #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions infrastructure-as-code/aws-ec2-instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,50 @@ This Terraform configuration provisions an EC2 instance in AWS.
By default, this configuration provisions a Ubuntu 14.04 Base Image AMI (with ID ami-2e1ef954) with type t2.micro in the us-east-1 region. The AMI ID, region, and type can all be set as variables. You can also set the name variable to determine the value set for the Name tag.

Note that you need to set environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

## Step-by-Step Execution

1. **Install Terraform**: Ensure that Terraform is installed on your machine. You can download it from [Terraform's official website](https://www.terraform.io/downloads.html).

2. **Clone the Repository**: Clone this repository to your local machine.
```sh
git clone https://github.com/hashicorp/terraform-guides.git
cd terraform-guides/infrastructure-as-code/aws-ec2-instance
```

3. **Set AWS Credentials**: You can either set your AWS credentials as environment variables or configure AWS CLI on your system.

**Option 1: Set environment variables**
```sh
export AWS_ACCESS_KEY_ID=your_access_key_id
export AWS_SECRET_ACCESS_KEY=your_secret_access_key
```

**Option 2: Configure AWS CLI**
```sh
aws configure
```

4. **Initialize Terraform**: Initialize the Terraform configuration.
```sh
terraform init
```

5. **Plan the Infrastructure**: Generate and review the execution plan.
```sh
terraform plan
```

6. **Apply the Configuration**: Apply the Terraform configuration to provision the EC2 instance.
```sh
terraform apply
```

7. **Verify the Instance**: After the apply command completes, you can verify the instance in the AWS Management Console.

8. **Destroy the Infrastructure**: When you no longer need the instance, you can destroy the infrastructure.
```sh
terraform destroy
```

Make sure to replace `your_access_key_id` and `your_secret_access_key` with your actual AWS credentials.
2 changes: 1 addition & 1 deletion infrastructure-as-code/aws-ec2-instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resource "aws_instance" "ubuntu" {
instance_type = "${var.instance_type}"
availability_zone = "${var.aws_region}a"

tags {
tags = {
Name = "${var.name}"
}
}