Skip to content

Commit

Permalink
Merge branch 'master' into huijbers/enable-rosetta-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Nov 5, 2021
2 parents 004b707 + cc8dd69 commit 1afd9e2
Show file tree
Hide file tree
Showing 62 changed files with 3,143 additions and 381 deletions.
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-codepipeline-actions/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export * from './s3/source-action';
export * from './stepfunctions/invoke-action';
export * from './servicecatalog/deploy-action-beta1';
export * from './action';

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CustomActionRegistration } from '../custom-action-registration';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
Expand Down Expand Up @@ -190,7 +189,7 @@ export class JenkinsProvider extends BaseJenkinsProvider {
}

private registerJenkinsCustomAction(id: string, category: codepipeline.ActionCategory) {
new CustomActionRegistration(this, id, {
new codepipeline.CustomActionRegistration(this, id, {
category,
artifactBounds: jenkinsArtifactsBounds,
provider: this.providerName,
Expand Down
34 changes: 34 additions & 0 deletions packages/@aws-cdk/aws-codepipeline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,40 @@ or you can use the `IStage.addAction()` method to mutate an existing Stage:
sourceStage.addAction(someAction);
```

## Custom Action Registration

To make your own custom CodePipeline Action requires registering the action provider. Look to the `JenkinsProvider` in `@aws-cdk/aws-codepipeline-actions` for an implementation example.

```ts
new codepipeline.CustomActionRegistration(this, 'GenericGitSourceProviderResource', {
category: codepipeline.ActionCategory.SOURCE,
artifactBounds: { minInputs: 0, maxInputs: 0, minOutputs: 1, maxOutputs: 1 },
provider: 'GenericGitSource',
version: '1',
entityUrl: 'https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-create-custom-action.html',
executionUrl: 'https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-create-custom-action.html',
actionProperties: [
{
name: 'Branch',
required: true,
key: false,
secret: false,
queryable: false,
description: 'Git branch to pull',
type: 'String',
},
{
name: 'GitUrl',
required: true,
key: false,
secret: false,
queryable: false,
description: 'SSH git clone URL',
type: 'String',
},
]
```
## Cross-account CodePipelines
> Cross-account Pipeline actions require that the Pipeline has *not* been
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import { Construct } from 'constructs';
import { ActionCategory, ActionArtifactBounds } from './action';
import { CfnCustomActionType } from './codepipeline.generated';

// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';
import { Construct as CoreConstruct } from '@aws-cdk/core';

/**
* The creation attributes used for defining a configuration property
Expand All @@ -13,22 +15,22 @@ export interface CustomActionProperty {
* The name of the property.
* You use this name in the `configuration` attribute when defining your custom Action class.
*/
name: string;
readonly name: string;

/**
* The description of the property.
*
* @default the description will be empty
*/
description?: string;
readonly description?: string;

/**
* Whether this property is a key.
*
* @default false
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codepipeline-customactiontype-configurationproperties.html#cfn-codepipeline-customactiontype-configurationproperties-key
*/
key?: boolean;
readonly key?: boolean;

/**
* Whether this property is queryable.
Expand All @@ -37,28 +39,28 @@ export interface CustomActionProperty {
* @default false
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codepipeline-customactiontype-configurationproperties.html#cfn-codepipeline-customactiontype-configurationproperties-queryable
*/
queryable?: boolean;
readonly queryable?: boolean;

/**
* Whether this property is required.
*/
required: boolean;
readonly required: boolean;

/**
* Whether this property is secret,
* like a password, or access key.
*
* @default false
*/
secret?: boolean;
readonly secret?: boolean;

/**
* The type of the property,
* like 'String', 'Number', or 'Boolean'.
*
* @default 'String'
*/
type?: string;
readonly type?: string;
}

/**
Expand All @@ -68,41 +70,44 @@ export interface CustomActionRegistrationProps {
/**
* The category of the Action.
*/
category: codepipeline.ActionCategory;
readonly category: ActionCategory;

/**
* The artifact bounds of the Action.
*/
artifactBounds: codepipeline.ActionArtifactBounds;
readonly artifactBounds: ActionArtifactBounds;

/**
* The provider of the Action.
* @example 'MyCustomActionProvider'
*/
provider: string;
readonly provider: string;

/**
* The version of your Action.
*
* @default '1'
*/
version?: string;
readonly version?: string;

/**
* The URL shown for the entire Action in the Pipeline UI.
* @default none
*/
entityUrl?: string;
readonly entityUrl?: string;

/**
* The URL shown for a particular execution of an Action in the Pipeline UI.
* @default none
*/
executionUrl?: string;
readonly executionUrl?: string;

/**
* The properties used for customizing the instance of your Action.
*
* @default []
*/
actionProperties?: CustomActionProperty[];
readonly actionProperties?: CustomActionProperty[];
}

/**
Expand All @@ -112,11 +117,11 @@ export interface CustomActionRegistrationProps {
* representing your custom Action, extending the Action class,
* and taking the `actionProperties` as properly typed, construction properties.
*/
export class CustomActionRegistration extends Construct {
constructor(parent: Construct, id: string, props: CustomActionRegistrationProps) {
super(parent, id);
export class CustomActionRegistration extends CoreConstruct {
constructor(scope: Construct, id: string, props: CustomActionRegistrationProps) {
super(scope, id);

new codepipeline.CfnCustomActionType(this, 'Resource', {
new CfnCustomActionType(this, 'Resource', {
category: props.category,
inputArtifactDetails: {
minimumCount: props.artifactBounds.minInputs,
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-codepipeline/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './action';
export * from './artifact';
export * from './pipeline';
export * from './custom-action-registration';

// AWS::CodePipeline CloudFormation Resources:
export * from './codepipeline.generated';
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cognito/lib/user-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ export class UserPool extends UserPoolBase {
*/
public addTrigger(operation: UserPoolOperation, fn: lambda.IFunction): void {
if (operation.operationName in this.triggers) {
throw new Error(`A trigger for the operation ${operation} already exists.`);
throw new Error(`A trigger for the operation ${operation.operationName} already exists.`);
}

this.addLambdaPermission(fn, operation.operationName);
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cognito/test/user-pool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ describe('User Pool', () => {

// WHEN
userpool.addTrigger(UserPoolOperation.CREATE_AUTH_CHALLENGE, fn1);
expect(() => userpool.addTrigger(UserPoolOperation.CREATE_AUTH_CHALLENGE, fn2)).toThrow(/already exists/);
expect(() => userpool.addTrigger(UserPoolOperation.CREATE_AUTH_CHALLENGE, fn2)).toThrow(/createAuthChallenge already exists/);
});

test('no username aliases specified', () => {
Expand Down
47 changes: 19 additions & 28 deletions packages/@aws-cdk/aws-dynamodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
Here is a minimal deployable DynamoDB table definition:

```ts
import * as dynamodb from '@aws-cdk/aws-dynamodb';

const table = new dynamodb.Table(this, 'Table', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING }
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
});
```

Expand All @@ -28,7 +26,8 @@ factory method. This method accepts table name or table ARN which describes the
existing table:

```ts
const table = Table.fromTableArn(this, 'ImportedTable', 'arn:aws:dynamodb:us-east-1:111111111:table/my-table');
declare const user: iam.User;
const table = dynamodb.Table.fromTableArn(this, 'ImportedTable', 'arn:aws:dynamodb:us-east-1:111111111:table/my-table');
// now you can just call methods on the table
table.grantReadWriteData(user);
```
Expand All @@ -50,11 +49,9 @@ DynamoDB supports two billing modes:
* PAY_PER_REQUEST - on-demand pricing and scaling. You only pay for what you use and there is no read and write capacity for the table or its global secondary indexes.

```ts
import * as dynamodb from '@aws-cdk/aws-dynamodb';

const table = new dynamodb.Table(this, 'Table', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
});
```

Expand All @@ -81,8 +78,6 @@ https://aws.amazon.com/blogs/database/how-to-use-aws-cloudformation-to-configure
You can create DynamoDB Global Tables by setting the `replicationRegions` property on a `Table`:

```ts
import * as dynamodb from '@aws-cdk/aws-dynamodb';

const globalTable = new dynamodb.Table(this, 'Table', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
replicationRegions: ['us-east-1', 'us-east-2', 'us-west-2'],
Expand All @@ -100,7 +95,7 @@ you have to make sure write auto-scaling is enabled for that Table:
const globalTable = new dynamodb.Table(this, 'Table', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
replicationRegions: ['us-east-1', 'us-east-2', 'us-west-2'],
billingMode: BillingMode.PROVISIONED,
billingMode: dynamodb.BillingMode.PROVISIONED,
});

globalTable.autoScaleWriteCapacity({
Expand Down Expand Up @@ -131,11 +126,9 @@ All user data stored in Amazon DynamoDB is fully encrypted at rest. When creatin
Creating a Table encrypted with a customer managed CMK:

```ts
import dynamodb = require('@aws-cdk/aws-dynamodb');

const table = new dynamodb.Table(stack, 'MyTable', {
const table = new dynamodb.Table(this, 'MyTable', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
encryption: TableEncryption.CUSTOMER_MANAGED,
encryption: dynamodb.TableEncryption.CUSTOMER_MANAGED,
});

// You can access the CMK that was added to the stack on your behalf by the Table construct via:
Expand All @@ -145,27 +138,24 @@ const tableEncryptionKey = table.encryptionKey;
You can also supply your own key:

```ts
import dynamodb = require('@aws-cdk/aws-dynamodb');
import kms = require('@aws-cdk/aws-kms');
import * as kms from '@aws-cdk/aws-kms';

const encryptionKey = new kms.Key(stack, 'Key', {
enableKeyRotation: true
const encryptionKey = new kms.Key(this, 'Key', {
enableKeyRotation: true,
});
const table = new dynamodb.Table(stack, 'MyTable', {
const table = new dynamodb.Table(this, 'MyTable', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
encryption: TableEncryption.CUSTOMER_MANAGED,
encryption: dynamodb.TableEncryption.CUSTOMER_MANAGED,
encryptionKey, // This will be exposed as table.encryptionKey
});
```

In order to use the AWS managed CMK instead, change the code to:

```ts
import dynamodb = require('@aws-cdk/aws-dynamodb');

const table = new dynamodb.Table(stack, 'MyTable', {
const table = new dynamodb.Table(this, 'MyTable', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
encryption: TableEncryption.AWS_MANAGED,
encryption: dynamodb.TableEncryption.AWS_MANAGED,
});

// In this case, the CMK _cannot_ be accessed through table.encryptionKey.
Expand All @@ -176,19 +166,20 @@ const table = new dynamodb.Table(stack, 'MyTable', {
To get the partition key and sort key of the table or indexes you have configured:

```ts
const { partitionKey, sortKey } = table.schema();
declare const table: dynamodb.Table;
const schema = table.schema();
const partitionKey = schema.partitionKey;
const sortKey = schema.sortKey;

// In case you want to get schema details for any secondary index

const { partitionKey, sortKey } = table.schema(INDEX_NAME);
// const { partitionKey, sortKey } = table.schema(INDEX_NAME);
```

## Kinesis Stream

A Kinesis Data Stream can be configured on the DynamoDB table to capture item-level changes.

```ts
import * as dynamodb from '@aws-cdk/aws-dynamodb';
import * as kinesis from '@aws-cdk/aws-kinesis';

const stream = new kinesis.Stream(this, 'Stream');
Expand Down
13 changes: 13 additions & 0 deletions packages/@aws-cdk/aws-dynamodb/rosetta/default.ts-fixture
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Fixture with packages imported, but nothing else
import { Construct } from 'constructs';
import { Duration, Stack } from '@aws-cdk/core';
import dynamodb = require('@aws-cdk/aws-dynamodb');
import iam = require('@aws-cdk/aws-iam');

class Fixture extends Stack {
constructor(scope: Construct, id: string) {
super(scope, id);

/// here
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export interface ApplicationLoadBalancedFargateServiceProps extends ApplicationL
readonly platformVersion?: FargatePlatformVersion;

/**
* The security groups to associate with the service. If you do not specify a security group, the default security group for the VPC is used.
* The security groups to associate with the service. If you do not specify a security group, a new security group is created.
*
* @default - A new security group is created.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export interface QueueProcessingFargateServiceProps extends QueueProcessingServi
readonly taskSubnets?: ec2.SubnetSelection;

/**
* The security groups to associate with the service. If you do not specify a security group, the default security group for the VPC is used.
* The security groups to associate with the service. If you do not specify a security group, a new security group is created.
*
* @default - A new security group is created.
*/
Expand Down
Loading

0 comments on commit 1afd9e2

Please sign in to comment.