Skip to content

Latest commit

 

History

History
100 lines (62 loc) · 3.17 KB

File metadata and controls

100 lines (62 loc) · 3.17 KB

Create Resources with Terraform

This folder contains a Terraform file that creates an Amazon SQS queue and stores its arn in AWS Systems Manager Parameter Store.

Requirements

Set up credentials

Terraform uses AWS access keys to provision and configure resources in your cloud environment.

Important: For security purposes, we recommend that you use IAM users instead of the root account for AWS access.

Setting your credentials for use by Terraform can be done in a number of ways, but here are the two recommended approaches:

  • Use the default credentials file:

    Set credentials in the AWS credentials profile file on your local system, located at:

    ~/.aws/credentials on Linux, macOS, or Unix

    C:\Users\USERNAME\.aws\credentials on Windows

    This file should contain lines in the following format:

    [default]
    aws_access_key_id = <your_access_key_id>
    aws_secret_access_key = <your_secret_access_key>

    Substitute your own AWS credentials values for the values <your_access_key_id> and <your_secret_access_key>.

  • Use environment variables:

    Set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.

    To set these variables on Linux, macOS, or Unix, use export:

    export AWS_ACCESS_KEY_ID=<your_access_key_id>
    export AWS_SECRET_ACCESS_KEY=<your_secret_access_key>

    To set these variables on Windows, use set:

    set AWS_ACCESS_KEY_ID=<your_access_key_id>
    set AWS_SECRET_ACCESS_KEY=<your_secret_access_key>

Deploy resources using Terraform

  • Navigate to the Terraform working directory at /terraform-sam-integration/terraform.

  • Initialize working directory.

    The first command that should be run after writing a new Terraform configuration is the terraform init command in order to initialize a working directory containing Terraform configuration files. It is safe to run this command multiple times.

    terraform init
  • Validate the changes.

    Run command:

    terraform plan
  • Deploy the changes.

    Run command:

    terraform apply
  • Copy the queue URL.

    When the terraform apply command completes, use the AWS console, you should see the URL of the queue as an output. Make note of this URL.

  • Deploy resources with SAM.

    To complete this project, you may now follow the instructions in this README to deploy resources using SAM.

  • Clean up.

    When you have finished with this project and you are ready to destroy your resources, cleanup your SAM resources by running this command from the sam directory:

    sam delete

    Then run the terraform cleanup command from this directory:

    terraform destroy