Want More Info? See the Poster
-
Core Utilities (for using stage.bash):
-
- For
cdk
usage, see CDK-GettingStarted.md
- For
-
Your AWS account and region info must be stored in an aws configuration & credential file
-
The easiest way to get the access key and secret key for your credential file:
-
Go to AWS Console and Find IAM Service
-
Access management -> Users, then Create user
-
This user does not need access to the AWS Management Console
-
When setting permissions, Attach policies directly
-
Add the
AdministratorAccess
Policy -
Once the User is created, go to their Security credentials tab and Create an access key
-
Disable this access key after deployment, or after performing actions with the
AdminClient
-
-
The easiest way to create the credential and config file is to use aws cli or aws toolkit plugin for IntelliJ
- The config file at a location like
~/.aws/config
should look like (replaceus-east-1
with whatever your desired region):
[default] region = us-east-1 output = json
- The credential file at a location like
~/.aws/credentials
should look like:
[default] aws_access_key_id = YOUR_ACCESS_KEY_HERE aws_secret_access_key = YOUR_SECRET_KEY_HERE
- The config file at a location like
-
-
Next you need to define the following environment variables:
-
AWS_ACCOUNT_ID
-
The AWS Account Id
-
In AWS Console, at the top right, click the drop-down to see your Account ID
- Set this environment variable to that number excluding any dashes
-
-
AWS_REGION
- The AWS Region (See Step 1)
-
ORG_FAMILYDIRECTORY_HOSTED_ZONE_NAME
- Should be a Fully-Qualified-Domain-Name (e.g.
example.com
,aws.example.com
, etc.) whose DNS should be controlled by Route53
- Should be a Fully-Qualified-Domain-Name (e.g.
-
ORG_FAMILYDIRECTORY_AMPLIFY_REPOSITORY_NAME
-
The name of your repository on GitHub containing the UI components
-
Unless you want to write your own UI, just fork FamilyDirectoryUI and set this Environment Variable to
FamilyDirectoryUI
-
-
ORG_FAMILYDIRECTORY_AMPLIFY_REPOSITORY_OWNER
- Your GitHub Username
-
ORG_FAMILYDIRECTORY_AMPLIFY_REPOSITORY_OAUTH_TOKEN
-
Fine-grained GitHub Token that ONLY gives access to
${ORG_FAMILYDIRECTORY_AMPLIFY_REPOSITORY_OWNER}/${ORG_FAMILYDIRECTORY_AMPLIFY_REPOSITORY_NAME}
and only allows read/write permissions for repository hooks -
This token only needs to be valid for each time you deploy the
AmplifyStack
-
To create this, go to GitHub Settings > Developer settings > Personal access tokens > Fine-grained tokens
-
Generate new token
-
Set Expiration to something short like 7 days
-
Repository Access: Only select repositories Your Fork/Repo Here
-
Permissions > Repository permissions > Webhooks > Access: Read and write
-
-
-
-
Now is a good time to bootstrap you're aws account for cdk if you haven't already (Note: You must be in the
CDK
directory to runcdk
commands)-
This only needs to be done once, before the first deployment:
-
cdk bootstrap "aws://$AWS_ACCOUNT_ID/$AWS_REGION"
-
cdk bootstrap "aws://$AWS_ACCOUNT_ID/us-east-1
(Only needed if your chosen region from step 1 is notus-east-1
)
-
-
-
If on a
*nix
system, you can use thestage.bash
script to build this project in the correct order-
If on Windows or other
non *nix
system, you will have to use thestage.bash
script as a guide to build this project manually- Do Not Attempt to use
stage.bash
on a system that does not use/
as the name-separator character
- Do Not Attempt to use
-
-
Now you can synth and deploy (Note: You must be in the
CDK
directory to runcdk
commands)-
First, deploy the
FamilyDirectoryDomainStack
solely (e.g.cdk deploy FamilyDirectoryDomainStack
)-
Before moving forward, login to the aws console and navigate to Route53, click on Hosted Zones in the right sidebar, then click on the Hosted Zone
-
Here, you need to copy the NS records for
${ORG_FAMILYDIRECTORY_HOSTED_ZONE_NAME}
and apply them at your registrar -
If
${ORG_FAMILYDIRECTORY_HOSTED_ZONE_NAME}
is a subdomain (e.g.subdomain.example.com
):-
Make sure that you are applying these records for the subdomain, not the root domain
-
Note that some DNS Providers/Registrars don't work very well for delegating domains. I had success when using Cloudflare as the Nameserver for my root domain. For these purposes, Cloudflare is free if you already own the root domain.
-
-
-
You will also need to set a temporary A record for
${ORG_FAMILYDIRECTORY_HOSTED_ZONE_NAME}
in your hosted zone's record table select Create record button and leave the record name blank, make sure Record type is A and set the TTL to something short like 300 seconds. The routing policy should be Simple routing and the Value of the record can be anything (this is a dummy record so that Route53 allows us to attach A records to subdomains and is overwritten by theFamilyDirectoryAmplifyStack
). You can use the value93.184.216.34
(which is the A record value ofexample.com
at the time of writing) -
Wait Until DNS Propagates, Then Continue
-
Now, deploy the
FamilyDirectoryCognitoStack
-
This stack should cause the following stacks to be deployed as well:
-
FamilyDirectorySesStack
-
FamilyDirectoryCognitoUsEastOneStack
-
FamilyDirectoryDynamoDbStack
-
-
This may take awhile, so please be patient
-
-
If you used the
stage.bash
script to build this repo, thenAdminClient
is already built for you-
Before continuing, you need to create the root member
-
The
AdminClient
has the capability to walk you through this -
Just run
AdminClient
, select CREATE command, then ROOT option, and fill in the prompts- Note do not try to create additional members or utilize other functions of
AdminClient
just yet
- Note do not try to create additional members or utilize other functions of
-
-
Now, deploy the
FamilyDirectoryApiGatewayStack
-
Now is a good time to use
AdminClient
to call TOOLKIT_CLEANER as well as prefill your FamilyDirectory with members-
TOOLKIT_CLEANER will free up unused S3 CDK assets reducing cost of your FamilyDirectory
- It is good practice to use TOOLKIT_CLEANER after all CDK deployments
-
-
Finally, we need to enable Production Access to SES
-
Go to SES in AWS Management Console
-
On the sidebar there is a Get set up option, click that
-
Then on the first section of that page there is a Request Production Access button, click that
-
For the Mail type select TRANSACTIONAL
-
For the Website URL enter
https://${ORG_FAMILYDIRECTORY_HOSTED_ZONE_NAME}
-
For the Use case description put something to the effect of
"For emailing account-holders of this application"
-
- It may take up to 24 hours for your Production Access Request to be approved, users are not able to sign-up until this is complete
-
The frontend is full CI/CD, so as long as you keep your fork in sync with FamilyDirectoryUI, new commits are automatically deployed to your frontend
For backend updates:
-
Follow steps 1, 2, & 4 from Steps to Deploy (We don't need to bootstrap, so step 3 is not needed)
-
Deploy the
FamilyDirectoryApiGatewayStack
(e.g.cdk deploy FamilyDirectoryApiGatewayStack
)- Note: You must be in the
CDK
directory to runcdk
commands
- Note: You must be in the
-
Remove Old Cdk Assets using
AdminClient
- Simply use the TOOLKIT_CLEANER Command after invoking the
AdminClient
- Simply use the TOOLKIT_CLEANER Command after invoking the