Skip to content

Commit

Permalink
Merge branch 'main' into fix_instances_reg_exp
Browse files Browse the repository at this point in the history
  • Loading branch information
moelasmar authored Jan 17, 2024
2 parents fb07b36 + a30a205 commit f462335
Show file tree
Hide file tree
Showing 16 changed files with 98 additions and 70 deletions.
18 changes: 17 additions & 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 Expand Up @@ -70,6 +70,22 @@ new appconfig.DeploymentStrategy(this, 'MyDeploymentStrategy', {
});
```

Importing a deployment strategy by ID:

```ts
appconfig.DeploymentStrategy.fromDeploymentStrategyId(this, 'MyImportedDeploymentStrategy', appconfig.DeploymentStrategyId.fromString('abc123'));
```

Importing an AWS AppConfig predefined deployment strategy by ID:

```ts
appconfig.DeploymentStrategy.fromDeploymentStrategyId(
this,
'MyImportedPredefinedDeploymentStrategy',
appconfig.DeploymentStrategyId.CANARY_10_PERCENT_20_MINUTES,
);
```

## Configuration

A configuration is a higher-level construct that can either be a `HostedConfiguration` (stored internally through AWS
Expand Down
8 changes: 2 additions & 6 deletions packages/@aws-cdk/aws-appconfig-alpha/awslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.IConfiguration",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.IApplication",

"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"
"events-generic",
"from-signature:@aws-cdk/aws-appconfig-alpha.DeploymentStrategy.fromDeploymentStrategyId.params[2]"
]
}
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
40 changes: 28 additions & 12 deletions packages/@aws-cdk/aws-appconfig-alpha/lib/deployment-strategy.ts
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 @@ -66,16 +66,16 @@ export class DeploymentStrategy extends Resource implements IDeploymentStrategy
* @param id The name of the deployment strategy construct
* @param deploymentStrategyId The ID of the deployment strategy
*/
public static fromDeploymentStrategyId(scope: Construct, id: string, deploymentStrategyId: string): IDeploymentStrategy {
public static fromDeploymentStrategyId(scope: Construct, id: string, deploymentStrategyId: DeploymentStrategyId): IDeploymentStrategy {
const stack = Stack.of(scope);
const deploymentStrategyArn = stack.formatArn({
service: 'appconfig',
resource: 'deploymentstrategy',
resourceName: deploymentStrategyId,
resourceName: deploymentStrategyId.id,
});

class Import extends Resource implements IDeploymentStrategy {
public readonly deploymentStrategyId = deploymentStrategyId;
public readonly deploymentStrategyId = deploymentStrategyId.id;
public readonly deploymentStrategyArn = deploymentStrategyArn;
}

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 Expand Up @@ -182,36 +182,52 @@ export enum GrowthType {
}

/**
* Defines the deployment strategy ID's of AWS AppConfig predefined strategies.
* Defines the deployment strategy ID's of AWS AppConfig deployment strategies.
*
* @see https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-creating-deployment-strategy.html
*/
export enum PredefinedDeploymentStrategyId {
export abstract class DeploymentStrategyId {
/**
* **AWS Recommended**. This strategy processes the deployment exponentially using a 10% growth factor over 20 minutes.
* AWS AppConfig recommends using this strategy for production deployments because it aligns with AWS best practices
* for configuration deployments.
*/
CANARY_10_PERCENT_20_MINUTES = 'AppConfig.Canary10Percent20Minutes',
public static readonly CANARY_10_PERCENT_20_MINUTES = DeploymentStrategyId.fromString('AppConfig.Canary10Percent20Minutes');

/**
* **Testing/Demonstration**. This strategy deploys the configuration to half of all targets every 30 seconds for a
* one-minute deployment. AWS AppConfig recommends using this strategy only for testing or demonstration purposes because
* it has a short duration and bake time.
*/
LINEAR_50_PERCENT_EVERY_30_SECONDS = 'AppConfig.Linear50PercentEvery30Seconds',
public static readonly LINEAR_50_PERCENT_EVERY_30_SECONDS = DeploymentStrategyId.fromString('AppConfig.Linear50PercentEvery30Seconds');

/**
* **AWS Recommended**. This strategy deploys the configuration to 20% of all targets every six minutes for a 30 minute deployment.
* AWS AppConfig recommends using this strategy for production deployments because it aligns with AWS best practices
* for configuration deployments.
*/
LINEAR_20_PERCENT_EVERY_6_MINUTES = 'AppConfig.Linear20PercentEvery6Minutes',
public static readonly LINEAR_20_PERCENT_EVERY_6_MINUTES = DeploymentStrategyId.fromString('AppConfig.Linear20PercentEvery6Minutes');

/**
* **Quick**. This strategy deploys the configuration to all targets immediately.
*/
ALL_AT_ONCE = 'AppConfig.AllAtOnce',
public static readonly ALL_AT_ONCE = DeploymentStrategyId.fromString('AppConfig.AllAtOnce');

/**
* Builds a deployment strategy ID from a string.
*
* @param deploymentStrategyId The deployment strategy ID.
*/
public static fromString(deploymentStrategyId: string): DeploymentStrategyId {
return {
id: deploymentStrategyId,
};
}

/**
* The deployment strategy ID.
*/
public abstract readonly id: string;
}

/**
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
Loading

0 comments on commit f462335

Please sign in to comment.