Deploying to Multiple AWS Accounts
Now that you have a couple of AWS accounts created and your resources have been parameterized, let’s look at how to deploy them. In this chapter, we’ll deploy the following:
The resources repo will be deployed in phases to the
prodstage. These two stages are configured in our
ProductionAWS accounts respectively.
Then we’ll do the same with the APIs repo.
Configure AWS Profiles
Follow the setup up IAM users chapter to create an IAM user in your
Development AWS account. And take a note of the Access key ID and Secret access key for the user.
Next, set these credentials in your local machine using the AWS CLI:
$ aws configure --profile default
This sets the default IAM credentials to those of the Development account. Meaning when you run
serverless deploy, a service will get deployed into the Development account.
Repeat the step to create an IAM user in your
Production account. And make a note of the credentials. We will not add the IAM credentials for the Production account on our local machine. This is because we do not want to be able to deploy code to the Production environment EVER from our local machine.
Production deployments should always go through our CI/CD pipeline.
Next we are going to deploy our two repos to our environments. We want you to follow along so you can get a really good sense of what the workflow is like.
So let’s start by using the demo repo templates from GitHub.
Create demo repos
Let’s first create the resources repo. Click Use this template.
Enter Repository name serverless-stack-demo-ext-resources and click Create repository from template.
And do the same for the API services repo.
Enter Repository name serverless-stack-demo-ext-api and click Create repository from template.
Now that we’ve forked these repos, let’s deploy them to our environments. We are going to use Seed to do this but you can set this up later with your favorite CI/CD tool.
For help and discussionComments on this chapter