Skip to content
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

Create sample Terraform configuration that can provision an AWS host #3

Open
emilyllim opened this issue Oct 10, 2023 · 2 comments
Open
Assignees

Comments

@emilyllim
Copy link
Collaborator

[D1] Terraform to AWS

This issue will include an overview of how I created an AWS account and the Terraform configuration used to provision an AWS EC2 instance.

Resources

@emilyllim emilyllim self-assigned this Oct 10, 2023
@emilyllim
Copy link
Collaborator Author

emilyllim commented Oct 10, 2023

Set up directory to store Terraform files

  • mkdir terraform
  • cd terraform

Install the AWS CLI

  • curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
  • unzip awscliv2.zip
  • sudo ./aws/install
  • aws --version

Prepare an AWS account for provisioning resources

  • Create an AWS Free Tier account
  • Using the root user, enable the IAM Identity Center
  • Create an AWS organization
  • Create an admin user by creating a new user and adding an administrative permission set
  • Using the admin user, create an IAM user with power user access
  • Create an access key for the new IAM user

Create the Terraform configuration

  • Use security credentials of that account to authenticate and authorize any requests
    • export AWS_ACCESS_KEY_ID=[ACCESS KEY ID VALUE]
    • export AWS_SECRET_ACCESS_KEY=[SECRET ACCESS KEY VALUE]
  • vi main.tf - create and edit the configuration file to define the EC2 instance

@emilyllim
Copy link
Collaborator Author

emilyllim commented Oct 10, 2023

Use Terraform to provision the instance

  • terraform init - initialize the directory, and download and install the defined providers
  • terraform apply - review the execution plan and then type yes to apply the configuration
  • The EC2 instance should be running and available to view on the AWS console

Destroy the instance

  • terraform destroy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant