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

fix(appconfig): prefix names with resource name #28742

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-appconfig-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Create an application with a name and description:

```ts
new appconfig.Application(this, 'MyApplication', {
name: 'App1',
applicationName: 'App1',
description: 'This is my application created through CDK.',
});
```
Expand Down
4 changes: 0 additions & 4 deletions packages/@aws-cdk/aws-appconfig-alpha/awslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@

"no-unused-type:@aws-cdk/aws-appconfig-alpha.PredefinedDeploymentStrategyId",
"ref-via-interface:@aws-cdk/aws-appconfig-alpha.Application.addAgentToEcs.taskDef",
"props-physical-name:@aws-cdk/aws-appconfig-alpha.ApplicationProps",
"props-physical-name:@aws-cdk/aws-appconfig-alpha.DeploymentStrategyProps",
"props-physical-name:@aws-cdk/aws-appconfig-alpha.EnvironmentProps",
"props-physical-name:@aws-cdk/aws-appconfig-alpha.ExtensionProps",
"events-in-interface",
"events-method-signature",
"events-generic"
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-appconfig-alpha/lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export interface ApplicationProps {
*
* @default - A name is generated.
*/
readonly name?: string;
readonly applicationName?: string;

/**
* The description for the application.
Expand Down Expand Up @@ -336,7 +336,7 @@ export class Application extends ApplicationBase {
super(scope, id);

this.description = props.description;
this.name = props.name || Names.uniqueResourceName(this, {
this.name = props.applicationName || Names.uniqueResourceName(this, {
maxLength: 64,
separator: '-',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface DeploymentStrategyProps {
*
* @default - A name is generated.
*/
readonly name?: string;
readonly deploymentStrategyName?: string;

/**
* A description of the deployment strategy.
Expand Down Expand Up @@ -130,15 +130,15 @@ export class DeploymentStrategy extends Resource implements IDeploymentStrategy

constructor(scope: Construct, id: string, props: DeploymentStrategyProps) {
super(scope, id, {
physicalName: props.name,
physicalName: props.deploymentStrategyName,
});

this.deploymentDurationInMinutes = props.rolloutStrategy.deploymentDuration.toMinutes();
this.growthFactor = props.rolloutStrategy.growthFactor;
this.description = props.description;
this.finalBakeTimeInMinutes = props.rolloutStrategy.finalBakeTime?.toMinutes();
this.growthType = props.rolloutStrategy.growthType;
this.name = props.name || Names.uniqueResourceName(this, {
this.name = props.deploymentStrategyName || Names.uniqueResourceName(this, {
maxLength: 64,
separator: '-',
});
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export interface EnvironmentOptions {
*
* @default - A name is generated.
*/
readonly name?: string;
readonly environmentName?: string;

/**
* The description of the environment.
Expand Down Expand Up @@ -236,10 +236,10 @@ export class Environment extends EnvironmentBase {

constructor(scope: Construct, id: string, props: EnvironmentProps) {
super(scope, id, {
physicalName: props.name,
physicalName: props.environmentName,
});

this.name = props.name || Names.uniqueResourceName(this, {
this.name = props.environmentName || Names.uniqueResourceName(this, {
maxLength: 64,
separator: '-',
});
Expand Down
10 changes: 5 additions & 5 deletions packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export interface ExtensionOptions {
*
* @default - A name is generated.
*/
readonly name?: string;
readonly extensionName?: string;

/**
* A description of the extension
Expand Down Expand Up @@ -493,11 +493,11 @@ export class Extension extends Resource implements IExtension {

constructor(scope: Construct, id: string, props: ExtensionProps) {
super(scope, id, {
physicalName: props.name,
physicalName: props.extensionName,
});

this.actions = props.actions;
this.name = props.name || Names.uniqueResourceName(this, {
this.name = props.extensionName || Names.uniqueResourceName(this, {
maxLength: 64,
separator: '-',
});
Expand Down Expand Up @@ -662,7 +662,7 @@ export class ExtensibleBase implements IExtensible {
}

private getExtensionForActionPoint(eventDestination: IEventDestination, actionPoint: ActionPoint, options?: ExtensionOptions) {
const name = options?.name || this.getExtensionDefaultName();
const name = options?.extensionName || this.getExtensionDefaultName();
const versionNumber = options?.latestVersionNumber ? options?.latestVersionNumber + 1 : 1;
const extension = new Extension(this.scope, `Extension${this.getExtensionHash(name, versionNumber)}`, {
actions: [
Expand All @@ -673,7 +673,7 @@ export class ExtensibleBase implements IExtensible {
],
}),
],
name,
extensionName: name,
...(options?.description ? { description: options.description } : {}),
...(options?.latestVersionNumber ? { latestVersionNumber: options.latestVersionNumber } : {}),
...(options?.parameters ? { parameters: options.parameters } : {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('appconfig', () => {
test('appconfig with name', () => {
const stack = new cdk.Stack();
new Application(stack, 'MyAppConfig', {
name: 'TestApp',
applicationName: 'TestApp',
});

Template.fromStack(stack).hasResourceProperties('AWS::AppConfig::Application', {
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('appconfig', () => {
});
appconfig.preCreateHostedConfigurationVersion(new LambdaDestination(func), {
description: 'This is my description',
name: 'MyExtension',
extensionName: 'MyExtension',
latestVersionNumber: 1,
parameters: [
Parameter.required('myparam', 'val'),
Expand Down
14 changes: 7 additions & 7 deletions packages/@aws-cdk/aws-appconfig-alpha/test/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('configuration', () => {
test('configuration with environments and no deployTo prop', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig', {
name: 'MyApplication',
applicationName: 'MyApplication',
});
app.addEnvironment('MyEnv1');
app.addEnvironment('MyEnv2');
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('configuration', () => {
test('configuration with environments and deployTo prop', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig', {
name: 'MyApplication',
applicationName: 'MyApplication',
});
app.addEnvironment('MyEnv1');
const env = app.addEnvironment('MyEnv2');
Expand Down Expand Up @@ -152,7 +152,7 @@ describe('configuration', () => {
test('configuration using deploy method and no environment associated', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig', {
name: 'MyApplication',
applicationName: 'MyApplication',
});
app.addEnvironment('MyEnv1');
const env = app.addEnvironment('MyEnv2');
Expand Down Expand Up @@ -191,7 +191,7 @@ describe('configuration', () => {
test('configuration using deploy method with environment associated', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig', {
name: 'MyApplication',
applicationName: 'MyApplication',
});
const env1 = app.addEnvironment('MyEnv1');
const env2 = app.addEnvironment('MyEnv2');
Expand Down Expand Up @@ -248,7 +248,7 @@ describe('configuration', () => {
test('configuration with no environment associated and no deploy method used', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig', {
name: 'MyApplication',
applicationName: 'MyApplication',
});
new HostedConfiguration(stack, 'MyHostedConfig', {
content: ConfigurationContent.fromInlineText('This is my content'),
Expand All @@ -267,7 +267,7 @@ describe('configuration', () => {
test('configuration with two configurations specified', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig', {
name: 'MyApplication',
applicationName: 'MyApplication',
});
const env1 = app.addEnvironment('MyEnv1');
const env2 = app.addEnvironment('MyEnv2');
Expand Down Expand Up @@ -382,7 +382,7 @@ describe('configuration', () => {
test('configuration with two configurations and no deployment strategy specified', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig', {
name: 'MyApplication',
applicationName: 'MyApplication',
});
const bucket = new Bucket(stack, 'MyBucket');
new HostedConfiguration(stack, 'MyHostedConfig', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('deployment strategy', () => {
test('deployment strategy with name', () => {
const stack = new cdk.Stack();
new DeploymentStrategy(stack, 'MyDeploymentStrategy', {
name: 'TestDeploymentStrategy',
deploymentStrategyName: 'TestDeploymentStrategy',
rolloutStrategy: RolloutStrategy.linear({
growthFactor: 10,
deploymentDuration: cdk.Duration.minutes(10),
Expand All @@ -44,7 +44,7 @@ describe('deployment strategy', () => {
test('deployment strategy duration in seconds', () => {
const stack = new cdk.Stack();
new DeploymentStrategy(stack, 'MyDeploymentStrategy', {
name: 'TestDeploymentStrategy',
deploymentStrategyName: 'TestDeploymentStrategy',
rolloutStrategy: RolloutStrategy.linear({
growthFactor: 10,
deploymentDuration: cdk.Duration.seconds(120),
Expand All @@ -63,7 +63,7 @@ describe('deployment strategy', () => {
test('deployment strategy with description', () => {
const stack = new cdk.Stack();
new DeploymentStrategy(stack, 'MyDeploymentStrategy', {
name: 'TestDeploymentStrategy',
deploymentStrategyName: 'TestDeploymentStrategy',
rolloutStrategy: RolloutStrategy.linear({
growthFactor: 10,
deploymentDuration: cdk.Duration.minutes(10),
Expand All @@ -84,7 +84,7 @@ describe('deployment strategy', () => {
test('deployment strategy with final bake time', () => {
const stack = new cdk.Stack();
new DeploymentStrategy(stack, 'MyDeploymentStrategy', {
name: 'TestDeploymentStrategy',
deploymentStrategyName: 'TestDeploymentStrategy',
rolloutStrategy: RolloutStrategy.linear({
growthFactor: 10,
deploymentDuration: cdk.Duration.minutes(10),
Expand All @@ -105,7 +105,7 @@ describe('deployment strategy', () => {
test('deployment strategy with growth type', () => {
const stack = new cdk.Stack();
new DeploymentStrategy(stack, 'MyDeploymentStrategy', {
name: 'TestDeploymentStrategy',
deploymentStrategyName: 'TestDeploymentStrategy',
rolloutStrategy: RolloutStrategy.exponential({
growthFactor: 10,
deploymentDuration: cdk.Duration.minutes(10),
Expand All @@ -124,7 +124,7 @@ describe('deployment strategy', () => {
test('deployment strategy with replicate to', () => {
const stack = new cdk.Stack();
new DeploymentStrategy(stack, 'MyDeploymentStrategy', {
name: 'TestDeploymentStrategy',
deploymentStrategyName: 'TestDeploymentStrategy',
rolloutStrategy: RolloutStrategy.linear({
growthFactor: 10,
deploymentDuration: cdk.Duration.minutes(10),
Expand Down
18 changes: 9 additions & 9 deletions packages/@aws-cdk/aws-appconfig-alpha/test/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('environment', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig');
new Environment(stack, 'MyEnvironment', {
name: 'TestEnv',
environmentName: 'TestEnv',
application: app,
});

Expand All @@ -41,7 +41,7 @@ describe('environment', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig');
new Environment(stack, 'MyEnvironment', {
name: 'TestEnv',
environmentName: 'TestEnv',
application: app,
description: 'This is my description',
});
Expand Down Expand Up @@ -72,7 +72,7 @@ describe('environment', () => {
assumedBy: new iam.ServicePrincipal('appconfig.amazonaws.com'),
});
const env = new Environment(stack, 'MyEnvironment', {
name: 'TestEnv',
environmentName: 'TestEnv',
application: app,
monitors: [Monitor.fromCloudWatchAlarm(alarm, alarmRole)],
});
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('environment', () => {
});
const app = new Application(stack, 'MyAppConfig');
const env = new Environment(stack, 'MyEnvironment', {
name: 'TestEnv',
environmentName: 'TestEnv',
application: app,
monitors: [Monitor.fromCloudWatchAlarm(alarm)],
});
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('environment', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig');
const env = new Environment(stack, 'MyEnvironment', {
name: 'TestEnv',
environmentName: 'TestEnv',
application: app,
monitors: [
Monitor.fromCfnMonitorsProperty({
Expand Down Expand Up @@ -203,7 +203,7 @@ describe('environment', () => {
const stack = new cdk.Stack();
const app = new Application(stack, 'MyAppConfig');
const env = new Environment(stack, 'MyEnvironment', {
name: 'TestEnv',
environmentName: 'TestEnv',
application: app,
monitors: [
Monitor.fromCfnMonitorsProperty({
Expand Down Expand Up @@ -247,7 +247,7 @@ describe('environment', () => {
alarmRule: alarm,
});
const env = new Environment(stack, 'MyEnvironment', {
name: 'TestEnv',
environmentName: 'TestEnv',
application: app,
monitors: [
Monitor.fromCloudWatchAlarm(compositeAlarm),
Expand Down Expand Up @@ -330,7 +330,7 @@ describe('environment', () => {
alarmRule: alarm,
});
const env = new Environment(stack, 'MyEnvironment', {
name: 'TestEnv',
environmentName: 'TestEnv',
application: app,
monitors: [
Monitor.fromCloudWatchAlarm(compositeAlarm1),
Expand Down Expand Up @@ -433,7 +433,7 @@ describe('environment', () => {
),
});
new Environment(stack, 'MyEnvironment', {
name: 'TestEnv',
environmentName: 'TestEnv',
application: app,
monitors: [
Monitor.fromCloudWatchAlarm(alarm1),
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-appconfig-alpha/test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ describe('extension', () => {
value: 'arn:lambda:us-east-1:123456789012:function:my-function',
});
const appconfig = new Application(stack, 'MyApplication', {
name: 'MyApplication',
applicationName: 'MyApplication',
});
const ext = new Extension(stack, 'MyExtension', {
actions: [
Expand All @@ -196,7 +196,7 @@ describe('extension', () => {
eventDestination: new LambdaDestination(func),
}),
],
name: 'TestExtension',
extensionName: 'TestExtension',
description: 'This is my extension',
parameters: [
Parameter.required('testVariable', 'hello'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const stack = new Stack(app, 'aws-appconfig-configuration');

// create application for config profile
const appConfigApp = new Application(stack, 'MyAppConfig', {
name: 'AppForConfigTest',
applicationName: 'AppForConfigTest',
});

const deploymentStrategy = new DeploymentStrategy(stack, 'MyDeployStrategy', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const stack = new Stack(app, 'aws-appconfig-environment');

// create resources needed for environment
const appForEnv = new Application(stack, 'MyApplicationForEnv', {
name: 'AppForEnvTest',
applicationName: 'AppForEnvTest',
});
const alarm = new Alarm(stack, 'MyAlarm', {
metric: new Metric({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const lambda = new Function(stack, 'MyFunction', {
code: Code.fromInline('def handler(event, context):\n\tprint(\'The function has been invoked.\')'),
});
const app = new Application(stack, 'MyApplication', {
name: 'AppForExtensionTest',
applicationName: 'AppForExtensionTest',
});
const lambdaExtension = new Extension(stack, 'MyLambdaExtension', {
actions: [
Expand Down
Loading