-
Notifications
You must be signed in to change notification settings - Fork 968
New serverless pattern - cdk-codepipeline-cross-account-deployment #1586
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
New serverless pattern - cdk-codepipeline-cross-account-deployment #1586
Conversation
I realized I am missing the pattern.json file, committing again shortly |
|
||
## Requirements | ||
|
||
* [Create AWS account(s)](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources. |
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 they need to have special permissions to do the cross account? if so please specify
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.
No additional permissions are required outside of the general requirements required for bootstrapping an environment. I added more info on the next commit about this.
|
||
## How It Works | ||
|
||
After cloning this pattern, you will bootstrap 2 AWS environments with CDK. An environment is an Account-Region pair. This example uses 2 different accounts as a way to demonstrate deploying the same CDK stack(s) across accounts i.e. Development and Production. The pipeline will only deploy in the account you designate in the app.py file. |
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 are many place where the accounts need to be defined. A better practice is to create a config file where the 2 accounts/regions are specified and then they are called from where you want to deploy. You can create a config_sample.json and upload that to github so you don't make your real config file public.
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 do agree that providing additional configuration, such as context in the cdk.json file to differentiate between the environments would normally be useful and cleaner, but in this case, we are only deploying 1 time from local, into the primary (environment with pipeline). After this, all deployments can be done through the pipeline through the CI/CD process. Therefore, the additional configuration wouldn't be needed, especially since we are only deploying to the one account locally the one time. Once the pipeline is initialized, the example static site will be deployed to the secondary account from the pipeline.
I added more info about this in the next commit.
``` | ||
## Testing | ||
|
||
1. After deploying, you can make changes in the repo, and push those changes to main. After these changes are pushed, navigate to the CodePipline dashboard and select the pipline to watch the CI/CD process. |
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.
in the CodeCommit repo
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.
So the pipeline wont deploy anything when you do the Cdk deploy of your stack locally? If that is the case please specify that, if not please add the testing steps so when you deploy with CDK you can see the 2 stacks in the 2 accounts, and then the step that you can make changes.
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.
More info about this info next commit
|
||
1. After deploying, you can make changes in the repo, and push those changes to main. After these changes are pushed, navigate to the CodePipline dashboard and select the pipline to watch the CI/CD process. | ||
|
||
2. After the pipline is complete, you can navigate to CloudFront in both accounts and see the distribution that has been created. The CloudFront dashboard will provide you with a URL you can use to navigate to the exmaple website that has been created. |
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.
pipeline
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.
fixed
## Cleanup | ||
|
||
1. Delete the stack in both accounts | ||
|
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.
and what about the pipeline?
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.
fixed with more info on next commit
Added some comments to the PR. Please review and fix and I will check it again next week. |
This pattern will be closed next week if there are no updates in this PR. Thanks, |
Sorry for delays, fixed all typos and added more information to readme. Thank you! |
I'm following the instructions here and i get an error in the cdk synth
Also nowehere in the readme it says how to configure the 2 accounts in the aws_serverless_pattern_cdk_crossaccount_deployment_stack file and in app.py is not clearly in the deployment instructions. |
Updated with changes |
Hello, im following the instructions but i get an error:
Please fix this before it can be merged |
This pattern has taken too much time/resources to process. Please focus on simpler patterns or submit as a repo instead. |
Issue #, if available:
Description of changes:
Created a new serverless pattern example that uses a CodePipeline in one account to deploy an example stack (S3 + CloudFront static site) to multiple accounts.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.