Skip to content

Commit 621e65f

Browse files
authored
Add AWS authentication section to README (#109)
Splits out a "How to authenticate to AWS accounts" section in the README, which includes more detailed instructions on how to authenticate using AWS SSO, including a newly created Bitwarden item with a sample `~/.aws/config`. Also adds a couple NPM commands for deploying to a particular account when using AWS SSO to authenticate.
1 parent aea34c1 commit 621e65f

2 files changed

Lines changed: 24 additions & 18 deletions

File tree

README.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,28 @@ The code can be deployed to either the dev account (`Innov-Platform-Dev`) or to
5454

5555
> :warning: Please be careful to deploy to the prod account only with extreme caution and after thoroughly testing changes in dev. **Make sure to test that API requests work in the browser before deploying to prod** (see [Test API Requests in the browser](#test-api-requests-in-the-browser) for instructions). This ensures that CORS is enabled properly.
5656
57-
### Steps to test dev/prod environments:
57+
### How to authenticate to AWS accounts
58+
59+
#### Option A: Use AWS SSO (Recommended)
5860
1. [Ensure AWS CLI is installed/up to date](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).
59-
2. [Configure](https://docs.aws.amazon.com/cli/v1/userguide/cli-configure-files.html) your `~/.aws/credentials` and `~/.aws/config` files with `dev` and `prod` profile names.
60-
3. Start an active AWS SSO session (run the `aws sso login` script).
61-
- **Note:** You need to be logged in before running synth or deploy.
62-
4. Run **synth scripts** to verify CloudFormation templates.
63-
64-
### Steps to deploy to the dev/prod AWS account:
65-
1. Make code changes locally.
66-
2. Test code changes locally.
67-
3. Log into AWS console, and open "Command line and programmatic access" option under the appropriate account.
68-
4. Save the account credentials to your `~/.aws/credentials` file.
69-
5. Run `export AWS_PROFILE=[PROFILE ID]` from your command line.
70-
6. Run **deploy scripts** to deploy this AWS CDK project to AWS.
71-
- **Note:**
72-
- If you don't run the scripts, you'll have to navigate to the `/infra` directory before deploying.
73-
- Running `npx cdk deploy` deploys this entire AWS CDK project to AWS. See individual scripts for stack-specific deploys.
61+
2. [Configure](https://docs.aws.amazon.com/cli/v1/userguide/cli-configure-files.html) your `~/.aws/config` files with `dev` and `prod` profiles. A sample `~/.aws/config` can be found in the ResX Bitwarden under the `
62+
Feedback API ~/.aws/config` item.
63+
3. Run `sso:login:dev` or `sso:login:prod` to start an active AWS SSO session with the desired account.
64+
65+
#### Option B: Set AWS environment variables
66+
1. Go to the AWS access portal.
67+
2. Click the desired account, and then click "Access keys"
68+
3. Export the environment variables under "Option 1: Set AWS environment variables" to your terminal.
69+
- These environment variables will expire after the session duration, so you will have to periodically re-export new variables following the instructions.
70+
71+
### Steps to deploy to the dev/prod AWS account
72+
To deploy this AWS CDK project to AWS
73+
- If you authenticated using AWS SSO (Option A):
74+
- Run `deploy:api:dev` or `deploy:api:prod` based on which account you want to deploy to.
75+
- If you authenticated by setting env vars (Option B):
76+
- Run `deploy:api`. The CDK project will be deployed to the account whose env vars you last exported.
77+
78+
**Note:** If you don't run the scripts, you'll have to navigate to the `/infra` directory before deploying. Running `npx cdk deploy` deploys this entire AWS CDK project to AWS. See individual scripts for stack-specific deploys.
7479

7580
## Test your service
7681

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
"scripts": {
77
"build": "tsc",
88
"cdk": "cdk",
9-
"deploy": "cdk deploy",
9+
"synth:api": "cd infra && npx cdk synth FeedbackApiStack",
1010
"deploy:api": "cd infra && npx cdk deploy FeedbackApiStack",
11+
"deploy:api:dev": "npm run deploy:api -- --profile dev",
12+
"deploy:api:prod": "npm run deploy:api -- --profile prod",
1113
"diff": "cdk diff",
1214
"lint": "eslint . --ext .ts",
1315
"prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write",
1416
"sso:login:dev": "aws sso login --profile dev",
1517
"sso:login:prod": "aws sso login --profile prod",
16-
"synth:api": "cd infra && npx cdk synth FeedbackApiStack",
1718
"test": "jest",
1819
"test:watch": "jest --watch",
1920
"typecheck": "tsc --noEmit --skipLibCheck",

0 commit comments

Comments
 (0)