-
Notifications
You must be signed in to change notification settings - Fork 74
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
add support for cdk diff
#1764
Labels
Comments
Marking as feature request. |
ykethan
added
feature-request
New feature or request
sandbox
Related to the sandbox experience
and removed
pending-triage
Incoming issues that need categorization
labels
Jul 19, 2024
@josefaidt FYI, one thing I've noticed since I've been able to use diffs is that even straight after a deploy, there are always differences, even without code changes. So, there might be some idempotency issues in the underlying constructs. For example
|
Implementation Steps:
Example Code (AWS CDK): import * as cdk from 'aws-cdk-lib';
import * as iam from 'aws-cdk-lib/aws-iam';
export class AmplifyBackendStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// Define IAM role for cdk diff command
const cdkDiffRole = new iam.Role(this, 'CdkDiffRole', {
assumedBy: new iam.ServicePrincipal('cdk.amazonaws.com'),
});
// Grant necessary permissions to cdk diff role
cdkDiffRole.addToPolicy(
new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: ['cloudformation:DescribeStacks', 'cloudformation:DescribeStackResources'],
resources: ['*'],
}),
);
// Define validation and approval process for changes
const validationLambda = new cdk.aws_lambda.Function(
this,
'ValidationLambda',
{
runtime: cdk.aws_lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
code: cdk.aws_lambda.Code.fromAsset('lambda'),
},
);
// Grant validation lambda execution role to cdk diff role
cdkDiffRole.grantExecute(validationLambda);
// Define IaC template for infrastructure changes
const infraTemplate = new cdk.aws_cloudformation.CloudFormationStack(
this,
'InfraTemplate',
{
templateBody: JSON.stringify({
Resources: {
MyResource: {
Type: 'AWS::EC2::Instance',
Properties: {
ImageId: 'ami-abc123',
},
},
},
}),
},
);
// Use version control system to track changes to IaC template
const gitRepo = new cdk.aws_codecommit.Repository(
this,
'GitRepo',
{
repositoryName: 'my-infra-repo',
},
);
// Grant git repo access to cdk diff role
cdkDiffRole.grantRead(gitRepo);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Environment information
Description
After making changes to my personal sandbox and opening a PR to merge to main/production, it would help the review process to better understand resource changes that are being made beyond the backend code diff.
For example,
this can be a part of check
or on its own
Currently diffs can be executed by recreating CDK commands
for branch
for sandbox
The text was updated successfully, but these errors were encountered: