Skip to content

Commit

Permalink
fix(appconfig): turn on awslint and fix linter errors (#27893)
Browse files Browse the repository at this point in the history
Most issues center around doc strings. I know nothing about appconfig, but I feel like there's massive value added to this module by providing even the cloudformation docs within cdk, so that they are accessible within the IDE. Some other linter rules I've added as exceptions, because I don't have the capacity to audit them, but they should be audited. Issue to track that work: #27894.

Labeled as a fix because technically, some public facing code has changed and also I want to make sure this ends up on the changelog.

BREAKING CHANGE: `Environment.fromEnvironmentAttributes` function signature changed; property called `attr` is now `attrs`. This should affect only Python users.
  - **appconfig**: `Extension.fromExtensionAttributes` function signature changed; property called `attr` is now `attrs`. This should affect only Python users.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
kaizencc authored and Mike Wrighton committed Nov 13, 2023
1 parent bc6eeac commit 60cfd4c
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 37 deletions.
51 changes: 37 additions & 14 deletions packages/@aws-cdk/aws-appconfig-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ Use AWS AppConfig, a capability of AWS Systems Manager, to create, manage, and q

## Application

In AWS AppConfig, an application is simply an organizational construct like a folder. This organizational construct has a relationship with some unit of executable code. For example, you could create an application called MyMobileApp to organize and manage configuration data for a mobile application installed by your users. Configurations and environments are associated with the application.
In AWS AppConfig, an application is simply an organizational construct like a folder. This organizational construct has a
relationship with some unit of executable code. For example, you could create an application called MyMobileApp to organize and
manage configuration data for a mobile application installed by your users. Configurations and environments are associated with
the application.

The name and description of an application are optional.

Expand All @@ -43,7 +46,8 @@ new appconfig.Application(this, 'MyApplication', {

## Deployment Strategy

A deployment strategy defines how a configuration will roll out. The roll out is defined by four parameters: deployment type, step percentage, deployment time, and bake time.
A deployment strategy defines how a configuration will roll out. The roll out is defined by four parameters: deployment type,
step percentage, deployment time, and bake time.
See: https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-creating-deployment-strategy.html

Deployment strategy with predefined values:
Expand All @@ -68,11 +72,15 @@ new appconfig.DeploymentStrategy(this, 'MyDeploymentStrategy', {

## Configuration

A configuration is a higher-level construct that can either be a `HostedConfiguration` (stored internally through AWS AppConfig) or a `SourcedConfiguration` (stored in an Amazon S3 bucket, AWS Secrets Manager secrets, Systems Manager (SSM) Parameter Store parameters, SSM documents, or AWS CodePipeline). This construct manages deployments on creation.
A configuration is a higher-level construct that can either be a `HostedConfiguration` (stored internally through AWS
AppConfig) or a `SourcedConfiguration` (stored in an Amazon S3 bucket, AWS Secrets Manager secrets, Systems Manager (SSM)
Parameter Store parameters, SSM documents, or AWS CodePipeline). This construct manages deployments on creation.

### HostedConfiguration

A hosted configuration represents configuration stored in the AWS AppConfig hosted configuration store. A hosted configuration takes in the configuration content and associated AWS AppConfig application. On construction of a hosted configuration, the configuration is deployed.
A hosted configuration represents configuration stored in the AWS AppConfig hosted configuration store. A hosted configuration
takes in the configuration content and associated AWS AppConfig application. On construction of a hosted configuration, the
configuration is deployed.

```ts
declare const application: appconfig.Application;
Expand Down Expand Up @@ -108,7 +116,9 @@ new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', {
});
```

When you create a configuration and configuration profile, you can specify up to two validators. A validator ensures that your configuration data is syntactically and semantically correct. You can create validators in either JSON Schema or as an AWS Lambda function.
When you create a configuration and configuration profile, you can specify up to two validators. A validator ensures that your
configuration data is syntactically and semantically correct. You can create validators in either JSON Schema or as an AWS
Lambda function.
See [About validators](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-creating-configuration-and-profile.html#appconfig-creating-configuration-and-profile-validators) for more information.

A hosted configuration with validators:
Expand All @@ -127,7 +137,8 @@ new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', {
});
```

You can attach a deployment strategy (as described in the previous section) to your configuration to specify how you want your configuration to roll out.
You can attach a deployment strategy (as described in the previous section) to your configuration to specify how you want your
configuration to roll out.

A hosted configuration with a deployment strategy:

Expand All @@ -147,7 +158,8 @@ new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', {
});
```

The `deployTo` parameter is used to specify which environments to deploy the configuration to. If this parameter is not specified, there will not be a deployment.
The `deployTo` parameter is used to specify which environments to deploy the configuration to. If this parameter is not
specified, there will not be a deployment.

A hosted configuration with `deployTo`:

Expand All @@ -164,7 +176,10 @@ new appconfig.HostedConfiguration(this, 'MyHostedConfiguration', {

### SourcedConfiguration

A sourced configuration represents configuration stored in an Amazon S3 bucket, AWS Secrets Manager secret, Systems Manager (SSM) Parameter Store parameter, SSM document, or AWS CodePipeline. A sourced configuration takes in the location source construct and optionally a version number to deploy. On construction of a sourced configuration, the configuration is deployed only if a version number is specified.
A sourced configuration represents configuration stored in an Amazon S3 bucket, AWS Secrets Manager secret, Systems Manager
(SSM) Parameter Store parameter, SSM document, or AWS CodePipeline. A sourced configuration takes in the location source
construct and optionally a version number to deploy. On construction of a sourced configuration, the configuration is deployed
only if a version number is specified.

### S3

Expand Down Expand Up @@ -309,7 +324,8 @@ new appconfig.SourcedConfiguration(this, 'MySourcedConfiguration', {
});
```

The `deployTo` parameter is used to specify which environments to deploy the configuration to. If this parameter is not specified, there will not be a deployment.
The `deployTo` parameter is used to specify which environments to deploy the configuration to. If this parameter is not
specified, there will not be a deployment.

A sourced configuration with `deployTo`:

Expand All @@ -327,7 +343,11 @@ new appconfig.SourcedConfiguration(this, 'MySourcedConfiguration', {

## Environment

For each AWS AppConfig application, you define one or more environments. An environment is a logical deployment group of AWS AppConfig targets, such as applications in a Beta or Production environment. You can also define environments for application subcomponents such as the Web, Mobile, and Back-end components for your application. You can configure Amazon CloudWatch alarms for each environment. The system monitors alarms during a configuration deployment. If an alarm is triggered, the system rolls back the configuration.
For each AWS AppConfig application, you define one or more environments. An environment is a logical deployment group of AWS
AppConfig targets, such as applications in a Beta or Production environment. You can also define environments for application
subcomponents such as the Web, Mobile, and Back-end components for your application. You can configure Amazon CloudWatch alarms
for each environment. The system monitors alarms during a configuration deployment. If an alarm is triggered, the system rolls
back the configuration.

Basic environment with monitors:

Expand All @@ -343,11 +363,13 @@ new appconfig.Environment(this, 'MyEnvironment', {
});
```

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.
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.
An extension augments your ability to inject logic or behavior at different points during the AWS AppConfig workflow of
creating or deploying a configuration.
See: https://docs.aws.amazon.com/appconfig/latest/userguide/working-with-appconfig-extensions.html

### AWS Lambda destination
Expand Down Expand Up @@ -438,7 +460,9 @@ new appconfig.Extension(this, 'MyExtension', {
});
```

You can also add extensions and their associations directly by calling `onDeploymentComplete()` or any other action point method on the AWS AppConfig application, configuration, or environment resource. To add an association to an existing extension, you can call `addExtension()` on the resource.
You can also add extensions and their associations directly by calling `onDeploymentComplete()` or any other action point
method on the AWS AppConfig application, configuration, or environment resource. To add an association to an existing
extension, you can call `addExtension()` on the resource.

Adding an association to an AWS AppConfig application:

Expand All @@ -450,4 +474,3 @@ declare const lambdaDestination: appconfig.LambdaDestination;
application.addExtension(extension);
application.onDeploymentComplete(lambdaDestination);
```

35 changes: 34 additions & 1 deletion packages/@aws-cdk/aws-appconfig-alpha/awslint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
{
"exclude": [
"*:*"
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.ConfigurationSourceType.S3",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.ConfigurationSourceType.SSM_DOCUMENT",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.ConfigurationSourceType.SSM_PARAMETER",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.ConfigurationSourceType.SECRETS_MANAGER",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.ConfigurationSourceType.CODE_PIPELINE",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.SourceType.LAMBDA",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.SourceType.SQS",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.SourceType.SNS",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.SourceType.EVENTS",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.Platform.ARM_64",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.Platform.X86_64",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.ActionPoint.PRE_CREATE_HOSTED_CONFIGURATION_VERSION",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.ActionPoint.PRE_START_DEPLOYMENT",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.ActionPoint.ON_DEPLOYMENT_START",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.ActionPoint.ON_DEPLOYMENT_STEP",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.ActionPoint.ON_DEPLOYMENT_BAKING",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.ActionPoint.ON_DEPLOYMENT_COMPLETE",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.ActionPoint.ON_DEPLOYMENT_ROLLED_BACK",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.IValidator",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.IExtension",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.IEnvironment",
"docs-public-apis:@aws-cdk/aws-appconfig-alpha.IDeploymentStrategy",
"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"
]
}
9 changes: 9 additions & 0 deletions packages/@aws-cdk/aws-appconfig-alpha/lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ export interface IApplication extends cdk.IResource {

/**
* The ID of the application.
* @attribute
*/
readonly applicationId: string;

/**
* The Amazon Resource Name (ARN) of the application.
* @attribute
*/
readonly applicationArn: string;

Expand Down Expand Up @@ -73,6 +75,9 @@ export interface IApplication extends cdk.IResource {
get environments(): IEnvironment[];
}

/**
* Properties for the Application construct
*/
export interface ApplicationProps {
/**
* The name of the application.
Expand Down Expand Up @@ -312,11 +317,15 @@ export class Application extends ApplicationBase {

/**
* The ID of the application.
*
* @attribute
*/
public readonly applicationId: string;

/**
* The Amazon Resource Name (ARN) of the application.
*
* @attribute
*/
public readonly applicationArn: string;

Expand Down
46 changes: 45 additions & 1 deletion packages/@aws-cdk/aws-appconfig-alpha/lib/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import { IEnvironment } from './environment';
import { ActionPoint, IEventDestination, ExtensionOptions, IExtension, IExtensible, ExtensibleBase } from './extension';
import { getHash } from './private/hash';

/**
* Options for the Configuration construct
*/
export interface ConfigurationOptions {
/**
* The deployment strategy for the configuration.
Expand Down Expand Up @@ -71,6 +74,9 @@ export interface ConfigurationOptions {
readonly deploymentKey?: kms.IKey;
}

/**
* Properties for the Configuration construct.
*/
export interface ConfigurationProps extends ConfigurationOptions {
/**
* The application associated with the configuration.
Expand Down Expand Up @@ -327,6 +333,9 @@ abstract class ConfigurationBase extends Construct implements IConfiguration, IE
}
}

/**
* Options for HostedConfiguration
*/
export interface HostedConfigurationOptions extends ConfigurationOptions {
/**
* The content of the hosted configuration.
Expand All @@ -348,6 +357,9 @@ export interface HostedConfigurationOptions extends ConfigurationOptions {
readonly versionLabel?: string;
}

/**
* Properties for HostedConfiguration
*/
export interface HostedConfigurationProps extends ConfigurationProps {
/**
* The content of the hosted configuration.
Expand All @@ -369,6 +381,9 @@ export interface HostedConfigurationProps extends ConfigurationProps {
readonly versionLabel?: string;
}

/**
* A hosted configuration represents configuration stored in the AWS AppConfig hosted configuration store.
*/
export class HostedConfiguration extends ConfigurationBase {
/**
* The content of the hosted configuration.
Expand Down Expand Up @@ -469,6 +484,9 @@ export class HostedConfiguration extends ConfigurationBase {
}
}

/**
* Options for SourcedConfiguration
*/
export interface SourcedConfigurationOptions extends ConfigurationOptions {
/**
* The location where the configuration is stored.
Expand All @@ -491,6 +509,9 @@ export interface SourcedConfigurationOptions extends ConfigurationOptions {
readonly retrievalRole?: iam.IRole;
}

/**
* Properties for SourcedConfiguration.
*/
export interface SourcedConfigurationProps extends ConfigurationProps {
/**
* The location where the configuration is stored.
Expand All @@ -513,6 +534,10 @@ export interface SourcedConfigurationProps extends ConfigurationProps {
readonly retrievalRole?: iam.IRole;
}

/**
* A sourced configuration represents configuration stored in an Amazon S3 bucket, AWS Secrets Manager secret, Systems Manager
* (SSM) Parameter Store parameter, SSM document, or AWS CodePipeline.
*/
export class SourcedConfiguration extends ConfigurationBase {
/**
* The location where the configuration is stored.
Expand Down Expand Up @@ -680,15 +705,34 @@ export class SourcedConfiguration extends ConfigurationBase {
* The configuration type.
*/
export enum ConfigurationType {
/**
* Freeform configuration profile. Allows you to store your data in the AWS AppConfig
* hosted configuration store or another Systems Manager capability or AWS service that integrates
* with AWS AppConfig.
*
* @see https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-free-form-configurations-creating.html
*/
FREEFORM = 'AWS.Freeform',

/**
* Feature flag configuration profile. This configuration stores its data
* in the AWS AppConfig hosted configuration store and the URI is simply hosted.
*/
FEATURE_FLAGS = 'AWS.AppConfig.FeatureFlags',
}

/**
* The validator type.
*/
export enum ValidatorType {
/**
* JSON Scema validator.
*/
JSON_SCHEMA = 'JSON_SCHEMA',

/**
* Validate using a Lambda function.
*/
LAMBDA = 'LAMBDA',
}

Expand All @@ -700,7 +744,7 @@ export enum ConfigurationSourceType {
SECRETS_MANAGER = 'SECRETS_MANAGER',
SSM_PARAMETER = 'SSM_PARAMETER',
SSM_DOCUMENT = 'SSM_DOCUMENT',
CODE_PIPELINE = 'CODE_PIPELINE'
CODE_PIPELINE = 'CODE_PIPELINE',
}

export interface IValidator {
Expand Down
Loading

0 comments on commit 60cfd4c

Please sign in to comment.