-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deploy to lambdas from cdk #111
base: master
Are you sure you want to change the base?
Conversation
server/persistence/mysql/mysql.go
Outdated
@@ -36,6 +36,7 @@ func NewFactory(ctx context.Context, config Config) (persistence.DBFactory, erro | |||
} | |||
|
|||
if config.RunCreateStmts { | |||
log.Println("Run Create Stmts...") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC I added these when I had no clue what I was doing and trying to get connected to RDS. Maybe we can clean these up?
server/setup.go
Outdated
ctx, fn := context.WithTimeout(context.Background(), 4*time.Minute) | ||
defer fn() | ||
|
||
log.Printf("Fetching DB (createTables: %v)\n", *createTables) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC I added these when I had no clue what I was doing and trying to get connected to RDS. Maybe we can clean these up?
infrastructure/lib/dns-stack.ts
Outdated
// TODO somewhere between the | ||
|
||
// TODO perhaps use https://github.com/aws-samples/aws-cdk-examples/blob/901ae3e11704fc378ade673f76f0eeae860a5daf/typescript/static-site/static-site.ts#L113-L127 | ||
// as an example for deploying CDN-like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a CDK plugin (library? idk what they're called) that makes deploying the frontend to S3+CloudFront like 3 lines. We should use that.
infrastructure/lib/dns-stack.ts
Outdated
// as an example for deploying CDN-like | ||
|
||
// TODO re-architect the frontend so that the "backend" calls go to a different sub-domain to hit | ||
// the lambda, and all of hobbycribbage.com/ just goes to a CDN to get the page. It's a SPA, so |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above link for pointing our domain at our CDN. As for the frontend changes, they'll be ezpz as well. Should just be swapping out or adding a baseURL.
but cors is preventing it still
… into deployToLambdasFromCDK Conflicts: .github/workflows/go_tests.yaml client/src/app/containers/Game/useGame.ts client/src/app/containers/Home/useActiveGames.ts client/src/auth/useAuth.ts docker-compose.yml go.mod go.sum server/persistence/dynamo/utils.go server/persistence/dynamo/utils_test.go server/server.go
…eployToLambdasFromCDK
name: Deploy to AWS | ||
|
||
on: | ||
pull_request: # for now, trigger this on PR so I can test it before merging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:badpokerface:
shell: bash | ||
|
||
jobs: | ||
dockerimage: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this? We're not using a docker image, right?
proxy: true, | ||
deployOptions: { | ||
stageName: 'urlprefix', | ||
// tracingEnabled: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌵 Do we need this still?
handler: props.lambda, | ||
proxy: true, | ||
deployOptions: { | ||
stageName: 'urlprefix', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 'urlprefix'
a special stage name, or will this make our URL http://something/urlprefix/
?
const subdomain = 'lambda.hobbycribbage.com'; | ||
restApi.addDomainName("domain_name", { | ||
domainName: subdomain, | ||
// securityPolicy: apigw.SecurityPolicy.TLS_1_2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌵 Do we still need this?
new ARecord(this, `${id}-r53-a-record`, { | ||
zone: zone, | ||
recordName: subdomain, | ||
comment: 'A comment on the ARecord', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:badpokerface:
}); | ||
|
||
// https://github.com/cszczepaniak/oh-hell-scorecard/blob/7ea3b0ff4ce229d035bd5b100560399ac56be48c/infrastructure/lib/infrastructure-stack.ts#L8-L12 | ||
const zipFileName = 'spa-bundle'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I missed this in the previous PR, but just like our lambda zip file, we may want to put the git commit hash in the name here if we want to be able to easily deploy different commits (the commit could be an input to the GitHub action if we add a manual deploy option, even)
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Install CDK and Stack Dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Maybe in a future improvement, we could split our frontend/backend CDK stacks and conditionally deploy them in our github actions based on the files touched in a given PR
What broke / What you're adding
I don't have a way to deploy the app to aws easily. AWS CDK provides a solution to that.
How you did it
@cszczepaniak wrote most of this. I just piggy-packed off what he made.
we're going to stand up a dynamoDB table, that is talked to via a lambda that executes our full server, and then a SPA will talk to it which is served via cloudfront.
How to test it and how to try to break it
make lambda spa-bundle
in the root directory.cd infrastructure
make deploy
to get the whole stack deployed to us-east-1.make install
to ensure that your credentials are set up appropriately.