Skip to content
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

feat(servicecatalogappregistry): Cross region warning and default application tag #23412

Merged
merged 3 commits into from Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -80,7 +80,7 @@ abstract class StackAssociatorBase implements IAspect {
}

if (node.region != this.application.env.region) {
this.error(node, 'AppRegistry does not support cross region associations. Application region '
this.warning(node, 'AppRegistry does not support cross region associations, deployment might fail if there is cross region stacks in the app. Application region '
+ this.application.env.region + ', stack region ' + node.region);
}
}
Expand Down
Expand Up @@ -100,6 +100,7 @@ class CreateTargetApplication extends TargetApplication {
applicationName: this.applicationOptions.applicationName,
description: this.applicationOptions.applicationDescription || 'Application containing stacks deployed via CDK.',
});
cdk.Tags.of(appRegApplication).add('managedBy', 'CDK_Application_Associator');

return {
application: appRegApplication,
Expand All @@ -123,4 +124,4 @@ class ExistingTargetApplication extends TargetApplication {
application: appRegApplication,
};
}
}
}
Expand Up @@ -15,13 +15,19 @@ describe('Scope based Associations with Application within Same Account', () =>
});
});
test('ApplicationAssociator will associate allStacks created inside cdkApp', () => {
new appreg.ApplicationAssociator(app, 'MyApplication', {
const appAssociator = new appreg.ApplicationAssociator(app, 'MyApplication', {
applications: [appreg.TargetApplication.createApplicationStack({
applicationName: 'MyAssociatedApplication',
stackName: 'MyAssociatedApplicationStack',
})],
});

const anotherStack = new AppRegistrySampleStack(app, 'SampleStack');
Template.fromStack(appAssociator.appRegistryApplication().stack).resourceCountIs('AWS::ServiceCatalogAppRegistry::Application', 1);
Template.fromStack(appAssociator.appRegistryApplication().stack).hasResourceProperties('AWS::ServiceCatalogAppRegistry::Application', {
Name: 'MyAssociatedApplication',
Tags: { managedBy: 'CDK_Application_Associator' },
});
Template.fromStack(anotherStack).resourceCountIs('AWS::ServiceCatalogAppRegistry::ResourceAssociation', 1);
Template.fromStack(anotherStack).hasResourceProperties('AWS::ServiceCatalogAppRegistry::ResourceAssociation', {
Application: 'MyAssociatedApplication',
Expand Down Expand Up @@ -103,7 +109,8 @@ describe('Scope based Associations with Application with Cross Region/Account',
const crossRegionStack = new cdk.Stack(app, 'crossRegionStack', {
env: { account: 'account', region: 'region' },
});
Annotations.fromStack(crossRegionStack).hasError('*', 'AppRegistry does not support cross region associations. Application region region2, stack region region');
Annotations.fromStack(crossRegionStack).hasWarning('*', 'AppRegistry does not support cross region associations, deployment might fail if there is cross region stacks in the app.'
+ ' Application region region2, stack region region');
});

test('Environment Agnostic ApplicationAssociator with cross region stacks inside cdkApp gives warning', () => {
Expand Down
Expand Up @@ -443,8 +443,9 @@ describe('Scope based Associations with Application with Cross Region/Account',
});
const stageStack = new cdk.Stack(stage, 'MyStack');
application.associateAllStacksInScope(stage);
Annotations.fromStack(stageStack).hasError('*',
'AppRegistry does not support cross region associations. Application region region, stack region region1');
Annotations.fromStack(stageStack).hasWarning('*',
'AppRegistry does not support cross region associations, deployment might fail if there is cross region stacks in the app.'
+ ' Application region region, stack region region1');
});
});

Expand Down
Expand Up @@ -249,7 +249,7 @@
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.168"
"version": "10.1.189"
}
}
},
Expand Down
@@ -1 +1 @@
{"version":"21.0.0"}
{"version":"22.0.0"}
@@ -1,5 +1,5 @@
{
"version": "20.0.0",
"version": "22.0.0",
"files": {
"3dece22dad73361a79cb380f2880362a20ffc5c0cc75ddc6707e26b5a88cf93f": {
"source": {
Expand Down
@@ -1,5 +1,5 @@
{
"version": "20.0.0",
"version": "22.0.0",
"testCases": {
"integ.attribute-group": {
"stacks": [
Expand Down
@@ -1,12 +1,6 @@
{
"version": "20.0.0",
"version": "22.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
},
"integ-servicecatalogappregistry-attribute-group.assets": {
"type": "cdk:asset-manifest",
"properties": {
Expand Down Expand Up @@ -77,6 +71,12 @@
]
},
"displayName": "integ-servicecatalogappregistry-attribute-group"
},
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
}
}
}
Expand Up @@ -4,14 +4,6 @@
"id": "App",
"path": "",
"children": {
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
}
},
"integ-servicecatalogappregistry-attribute-group": {
"id": "integ-servicecatalogappregistry-attribute-group",
"path": "integ-servicecatalogappregistry-attribute-group",
Expand Down Expand Up @@ -97,6 +89,14 @@
"id": "MyRole",
"path": "integ-servicecatalogappregistry-attribute-group/MyRole",
"children": {
"ImportMyRole": {
"id": "ImportMyRole",
"path": "integ-servicecatalogappregistry-attribute-group/MyRole/ImportMyRole",
"constructInfo": {
"fqn": "@aws-cdk/core.Resource",
"version": "0.0.0"
}
},
"Resource": {
"id": "Resource",
"path": "integ-servicecatalogappregistry-attribute-group/MyRole/Resource",
Expand Down Expand Up @@ -147,6 +147,14 @@
"id": "MySecondRole",
"path": "integ-servicecatalogappregistry-attribute-group/MySecondRole",
"children": {
"ImportMySecondRole": {
"id": "ImportMySecondRole",
"path": "integ-servicecatalogappregistry-attribute-group/MySecondRole/ImportMySecondRole",
"constructInfo": {
"fqn": "@aws-cdk/core.Resource",
"version": "0.0.0"
}
},
"Resource": {
"id": "Resource",
"path": "integ-servicecatalogappregistry-attribute-group/MySecondRole/Resource",
Expand Down Expand Up @@ -192,17 +200,41 @@
"fqn": "@aws-cdk/aws-iam.Role",
"version": "0.0.0"
}
},
"BootstrapVersion": {
"id": "BootstrapVersion",
"path": "integ-servicecatalogappregistry-attribute-group/BootstrapVersion",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnParameter",
"version": "0.0.0"
}
},
"CheckBootstrapVersion": {
"id": "CheckBootstrapVersion",
"path": "integ-servicecatalogappregistry-attribute-group/CheckBootstrapVersion",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnRule",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/core.Stack",
"version": "0.0.0"
}
},
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"version": "10.1.189"
}
}
},
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.85"
"fqn": "@aws-cdk/core.App",
"version": "0.0.0"
}
}
}