Setting up the configuration files for your AWS account

I've created a configuration file called common-variables.sh for each serverless project under ./bash/, which creates environment variables that are used by the AWS CLI and SAM. You will need to modify them with your AWS account details. This is done to lay the groundwork to support multiple AWS accounts in more than one region. Here is an example of common-variables.sh:

#!/bin/sh
export profile="demo"
export region="<your-aws-region>"
export aws_account_id=$(aws sts get-caller-identity --query 'Account' --profile $profile | tr -d '"')
# export aws_account_id="<your-aws-accountid>"
export template="lambda-dynamo-data-api"
export bucket="<you-bucket-name>"
export prefix="tmp/sam"

# Lambda settings
export zip_file="lambda-dynamo-data-api.zip"
export files="lambda_return_dynamo_records.py"

Let's try to understand the code:

  • Update <your-aws-region> with your AWS region, such as us-east-1.
  • I'm dynamically determining the aws_account_id, but you can also hardcode it as shown in the comments, in which case uncomment the line and update <your-aws-accountid> with your AWS account ID. If you do not know it, you can find your account number in the AWS Management Console | Support | Support Center screen.
  • template is the name of the SAM template that we will be using.
  • bucket and prefix define the location of the deployed Lambda package.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset