Beep infrastructure is defined and managed using the AWS CDK.
- Install the AWS CLI
- Specify your AWS CLI credentials and region
- Install Node.js
npm install -g aws-cdk
npm install
Always consult with your local AWS specialist before deployment, if you are unsure of what you are doing.
Before deploying the stack for the first time, there must be a hosted zone present in route 53. This hosted zone must manage the domain name that you pass to the BeepStack constructor in beep-infrastructure.ts
:
new BeepStack(app, 'Beep', {
env: {
account: 'xxxxxxxxxxxx',
region: 'eu-west-1'
},
domainName: 'stichtingbeep.nl',
});
If you have recently created this hosted zone, you should wait 24-48 hours for the DNS records to properly propagate, before you deploy the stack for the first time (or change the domain name). If you do not do this, the certificate generation process will fail, because this process uses DNS validation to automatically validate requested certificates.
For email sending, you must have an active SES configuration. In the cognito file you must add the correct ARN for the from address.
When you deploy the stack for the first time, make sure to set the desired service count to 0, because the images do not yet exist.
Before you deploy the updated app, evaluate the difference between the AWS CDK app and the deployed app:
cdk diff
Deploy the changes:
cdk deploy Beep*
Use the reference documentation to get an understanding of the concepts.
In order to debug, add a Run/debug configuration in WebStorm:
Run > Edit Configurations...
Under Javascript file
add the path to your CDK binary e.g. ~/.nvm/versions/node/v12.7.0/bin/cdk
.
Under Application parameters
add the CDK command you want to debug for, e.g. diff
Name the command after the CDK command you want to debug e.g. cdk diff
.
If you are using a specific profile, do not forget to add the --profile
argument with the profile name.
Set a breakpoint and click debug next to the run configuration in the top right.
- Install the Session Manager Plugin Plugin for AWS CLI
- Log into the bastion instance:
aws ssm start-session --target i-096eca4a81f445b75
- Assume the
ec2-user
:$ sudo -i # su ec2-user
- Add your own public key to the authorized_keys file of the ec2-user
- Add the following to your ssh config
Note If you are using a different profile in aws, make sure to include the --profile argument
Host i-* mi-* ProxyCommand sh -c "PATH=$PATH:/usr/local/bin /usr/local/bin/aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"
The PATH=$PATH:/usr/local/bin
in front of the command is necessary if you use Sequel Pro (Mac). For some reason it doesn't respect the user paths and fails to find aws cli and session plugin