The terraform configuration creates and integrates an AWS API Gateway with a AWS Simple Queue Service.
- AWS API Gateway
- AWS SQS
- AWS IAM Roles : AWS CloudWatch and SQS access
- AWS IAM policy
If you have Homebrew installed you can install terraform by typing
$ brew install terraform
Otherwise, please download the latest version of terraform binary here.
-
An AWS bucket must exist with the same name as in the main.tf file:
backend "s3" { bucket = "apigw-sqs-salesforce" key = "non-prod/dev.tfstate" region = "us-east-1" dynamodb_table = "s3-state-lock" encrypt = true }
The bucket can be called anything, the config must be updated to match the bucket name. The AWS account used to run the script must have permissions to add/update on the s3 bucket.
-
A DynamoDb table must exist with the same name as the dynamodb_table attribite in the config file
Once the terraform binary is installed, run the below commands;
- To check if the terraform is installed properly.
$ terraform -version
The terraform code is configured to use the s3 bucket as remote backend for storing and managing the terraform state file. A DynamoDB table takes cares of the state locking mechanism, i.e., it prevents another user from triggering an infra build at the same time.
Note : The AWS CLI should be installed and configured with sufficient user level permissions for enabling the terraform to create aws resources.
Note : A separate AWS account must be used run terraform with production/non-production properties.
- Initialize terraform configuration.
$ terraform init
- Create a terraform plan.
$ terraform plan -var-file="dev.tfvars"
- Deploy the terraform configuration.
$ terraform apply --auto-approve -var-file="dev.tfvars"