Skip to content

Commit

Permalink
Merge branch 'main' into gh-27545
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Oct 26, 2023
2 parents 7a7a66e + 7e426c8 commit 9001791
Show file tree
Hide file tree
Showing 15 changed files with 289 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@
},
{
"Key": "idle_timeout.timeout_seconds",
"Value": "400"
"Value": "5"
}
],
"Scheme": "internet-facing",
Expand Down Expand Up @@ -1101,7 +1101,7 @@
},
{
"Key": "idle_timeout.timeout_seconds",
"Value": "400"
"Value": "500"
}
],
"Scheme": "internet-facing",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ new ApplicationMultipleTargetGroupsEc2Service(stack, 'myService', {
loadBalancers: [
{
name: 'lb',
idleTimeout: Duration.seconds(400),
idleTimeout: Duration.seconds(5),
domainName: 'api.example.com',
domainZone: zone,
listeners: [
Expand All @@ -41,7 +41,7 @@ new ApplicationMultipleTargetGroupsEc2Service(stack, 'myService', {
},
{
name: 'lb2',
idleTimeout: Duration.seconds(400),
idleTimeout: Duration.seconds(500),
domainName: 'frontend.example.com',
domainZone: zone,
listeners: [
Expand Down
6 changes: 4 additions & 2 deletions packages/@aws-cdk/aws-appconfig-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,13 @@ declare const alarm: cloudwatch.Alarm;
new appconfig.Environment(this, 'MyEnvironment', {
application,
monitors: [
{alarm},
]
appconfig.Monitor.fromCloudWatchAlarm(alarm),
],
});
```

Environment monitors also support L1 CfnEnvironment.MonitorsProperty constructs. However, this is not the recommended approach for CloudWatch alarms because a role will not be auto-generated if not provided.

## Extension

An extension augments your ability to inject logic or behavior at different points during the AWS AppConfig workflow of creating or deploying a configuration.
Expand Down
8 changes: 8 additions & 0 deletions packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,15 @@ export interface HostedConfigurationOptions extends ConfigurationOptions {

/**
* The latest version number of the hosted configuration.
*
* @default - None.
*/
readonly latestVersionNumber?: number;

/**
* The version label of the hosted configuration.
*
* @default - None.
*/
readonly versionLabel?: string;
}
Expand All @@ -352,11 +356,15 @@ export interface HostedConfigurationProps extends ConfigurationProps {

/**
* The latest version number of the hosted configuration.
*
* @default - None.
*/
readonly latestVersionNumber?: number;

/**
* The version label of the hosted configuration.
*
* @default - None.
*/
readonly versionLabel?: string;
}
Expand Down
62 changes: 53 additions & 9 deletions packages/@aws-cdk/aws-appconfig-alpha/lib/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,22 @@ export interface EnvironmentAttributes {

/**
* The name of the environment.
*
* @default - None.
*/
readonly name?: string;

/**
* The description of the environment.
*
* @default - None.
*/
readonly description?: string;

/**
* The monitors for the environment.
*
* @default - None.
*/
readonly monitors?: Monitor[];
}
Expand Down Expand Up @@ -238,8 +244,10 @@ export class Environment extends EnvironmentBase {
description: this.description,
monitors: this.monitors?.map((monitor, index) => {
return {
alarmArn: monitor.alarm.alarmArn,
alarmRoleArn: monitor.alarmRole?.roleArn || this.createAlarmRole(monitor.alarm.alarmArn, index).roleArn,
alarmArn: monitor.alarmArn,
...(monitor.monitorType === MonitorType.CLOUDWATCH
? { alarmRoleArn: monitor.alarmRoleArn || this.createAlarmRole(monitor.alarmArn, index).roleArn }
: { alarmRoleArn: monitor.alarmRoleArn }),
};
}),
});
Expand Down Expand Up @@ -276,21 +284,57 @@ export class Environment extends EnvironmentBase {
}
}

export enum MonitorType {
CLOUDWATCH,
CFN_MONITORS_PROPERTY,
}

/**
* Defines monitors that will be associated with an AWS AppConfig environment.
*/
export interface Monitor {
export abstract class Monitor {
/**
* The Amazon CloudWatch alarm.
*/
readonly alarm: cloudwatch.IAlarm;
* Creates a Monitor from a CloudWatch alarm. If the alarm role is not specified, a role will
* be generated.
*
* @param alarm The Amazon CloudWatch alarm.
* @param alarmRole The IAM role for AWS AppConfig to view the alarm state.
*/
public static fromCloudWatchAlarm(alarm: cloudwatch.IAlarm, alarmRole?: iam.IRole): Monitor {
return {
alarmArn: alarm.alarmArn,
alarmRoleArn: alarmRole?.roleArn,
monitorType: MonitorType.CLOUDWATCH,
};
}

/**
* The IAM role for AWS AppConfig to view the alarm state.
* Creates a Monitor from a CfnEnvironment.MonitorsProperty construct.
*
* @default - A role is generated.
* @param monitorsProperty The monitors property.
*/
public static fromCfnMonitorsProperty(monitorsProperty: CfnEnvironment.MonitorsProperty): Monitor {
return {
alarmArn: monitorsProperty.alarmArn!,
alarmRoleArn: monitorsProperty.alarmRoleArn,
monitorType: MonitorType.CFN_MONITORS_PROPERTY,
};
}

/**
* The alarm ARN for AWS AppConfig to monitor.
*/
public abstract readonly alarmArn: string;

/**
* The type of monitor.
*/
public abstract readonly monitorType: MonitorType;

/**
* The IAM role ARN for AWS AppConfig to view the alarm state.
*/
readonly alarmRole?: iam.IRole;
public abstract readonly alarmRoleArn?: string;
}

export interface IEnvironment extends IResource {
Expand Down
8 changes: 8 additions & 0 deletions packages/@aws-cdk/aws-appconfig-alpha/lib/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,21 +290,29 @@ export interface ExtensionAttributes {

/**
* The Amazon Resource Name (ARN) of the extension.
*
* @default - The extension ARN is generated.
*/
readonly extensionArn?: string;

/**
* The actions of the extension.
*
* @default - None.
*/
readonly actions?: Action[];

/**
* The name of the extension.
*
* @default - None.
*/
readonly name?: string;

/**
* The description of the extension.
*
* @default - None.
*/
readonly description?: string;
}
Expand Down
Loading

0 comments on commit 9001791

Please sign in to comment.