Skip to content

Commit

Permalink
Merge branch 'master' into provider-lambda-role-support
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Jun 7, 2021
2 parents 330733a + 775a0c9 commit d9ca70c
Show file tree
Hide file tree
Showing 43 changed files with 837 additions and 284 deletions.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"fs-extra": "^9.1.0",
"graceful-fs": "^4.2.6",
"jest-junit": "^12.1.0",
"jsii-diff": "^1.29.0",
"jsii-pacmak": "^1.29.0",
"jsii-reflect": "^1.29.0",
"jsii-rosetta": "^1.29.0",
"jsii-diff": "^1.30.0",
"jsii-pacmak": "^1.30.0",
"jsii-reflect": "^1.30.0",
"jsii-rosetta": "^1.30.0",
"lerna": "^4.0.0",
"patch-package": "^6.4.7",
"standard-version": "^9.3.0",
Expand Down Expand Up @@ -97,6 +97,8 @@
"@aws-cdk/core/minimatch/**",
"@aws-cdk/cx-api/semver",
"@aws-cdk/cx-api/semver/**",
"@aws-cdk/aws-events-targets/aws-sdk",
"@aws-cdk/aws-events-targets/aws-sdk/**",
"@aws-cdk/yaml-cfn/yaml",
"@aws-cdk/yaml-cfn/yaml/**",
"aws-cdk-lib/@balena/dockerignore",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/app-delivery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@types/nodeunit": "^0.0.31",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"fast-check": "^2.14.0",
"fast-check": "^2.16.0",
"nodeunit": "^0.11.3",
"pkglint": "0.0.0",
"@aws-cdk/assert-internal": "0.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"license": "Apache-2.0",
"devDependencies": {
"@types/jest": "^26.0.23",
"@types/aws-lambda": "^8.10.76",
"@types/aws-lambda": "^8.10.77",
"@aws-cdk/aws-apigatewayv2-integrations": "0.0.0",
"@aws-cdk/aws-lambda": "0.0.0",
"cdk-build-tools": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-applicationautoscaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@types/nodeunit": "^0.0.31",
"cdk-build-tools": "0.0.0",
"cfn2ts": "0.0.0",
"fast-check": "^2.14.0",
"fast-check": "^2.16.0",
"nodeunit": "^0.11.3",
"pkglint": "0.0.0",
"@aws-cdk/assert-internal": "0.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-autoscaling-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@types/nodeunit": "^0.0.31",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"fast-check": "^2.14.0",
"fast-check": "^2.16.0",
"nodeunit": "^0.11.3",
"pkglint": "0.0.0",
"@aws-cdk/assert-internal": "0.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@types/aws-lambda": "^8.10.76",
"@types/aws-lambda": "^8.10.77",
"@types/sinon": "^9.0.11",
"cdk-build-tools": "0.0.0",
"aws-sdk": "^2.596.0",
"aws-sdk-mock": "^5.1.0",
"eslint": "^7.27.0",
"eslint": "^7.28.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.23.3",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-standard": "^4.1.0",
"jest": "^26.6.3",
"lambda-tester": "^3.6.0",
"sinon": "^9.2.4",
"nock": "^13.0.11",
"nock": "^13.1.0",
"ts-jest": "^26.5.6"
}
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudformation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@aws-cdk/aws-sns-subscriptions": "0.0.0",
"@aws-cdk/aws-sqs": "0.0.0",
"@aws-cdk/aws-ssm": "0.0.0",
"@types/aws-lambda": "^8.10.76",
"@types/aws-lambda": "^8.10.77",
"@types/nodeunit": "^0.0.31",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
"devDependencies": {
"aws-sdk": "^2.596.0",
"aws-sdk-mock": "^5.1.0",
"eslint": "^7.27.0",
"eslint": "^7.28.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.23.3",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-standard": "^4.1.0",
"jest": "^26.6.3",
"lambda-tester": "^3.6.0",
"nock": "^13.0.11"
"nock": "^13.1.0"
}
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-dynamodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@types/aws-lambda": "^8.10.76",
"@types/aws-lambda": "^8.10.77",
"@types/jest": "^26.0.23",
"@types/sinon": "^9.0.11",
"aws-sdk": "^2.848.0",
Expand Down
17 changes: 17 additions & 0 deletions packages/@aws-cdk/aws-ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,23 @@ new ec2.LaunchTemplate(stack, '', {
For more information see
[Specifying Multiple User Data Blocks Using a MIME Multi Part Archive](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/bootstrap_container_instance.html#multi-part_user_data)

#### Using add*Command on MultipartUserData

To use the `add*Command` methods, that are inherited from the `UserData` interface, on `MultipartUserData` you must add a part
to the `MultipartUserData` and designate it as the reciever for these methods. This is accomplished by using the `addUserDataPart()`
method on `MultipartUserData` with the `makeDefault` argument set to `true`:

```ts
const multipartUserData = new ec2.MultipartUserData();
const commandsUserData = ec2.UserData.forLinux();
multipartUserData.addUserDataPart(commandsUserData, MultipartBody.SHELL_SCRIPT, true);

// Adding commands to the multipartUserData adds them to commandsUserData, and vice-versa.
multipartUserData.addCommands('touch /root/multi.txt');
commandsUserData.addCommands('touch /root/userdata.txt');
```

When used on an EC2 instance, the above `multipartUserData` will create both `multi.txt` and `userdata.txt` in `/root`.

## Importing existing subnet

Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-ec2/lib/security-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,9 @@ export class SecurityGroup extends SecurityGroupBase {
// In the case of "allowAllOutbound", we don't add any more rules. There
// is only one rule which allows all traffic and that subsumes any other
// rule.
Annotations.of(this).addWarning('Ignoring Egress rule since \'allowAllOutbound\' is set to true; To add customize rules, set allowAllOutbound=false on the SecurityGroup');
if (!remoteRule) { // Warn only if addEgressRule() was explicitely called
Annotations.of(this).addWarning('Ignoring Egress rule since \'allowAllOutbound\' is set to true; To add customize rules, set allowAllOutbound=false on the SecurityGroup');
}
return;
} else {
// Otherwise, if the bogus rule exists we can now remove it because the
Expand Down
62 changes: 48 additions & 14 deletions packages/@aws-cdk/aws-ec2/lib/user-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,15 @@ export interface MultipartUserDataOptions {
*
*/
export class MultipartUserData extends UserData {
private static readonly USE_PART_ERROR = 'MultipartUserData does not support this operation. Please add part using addPart.';
private static readonly USE_PART_ERROR = 'MultipartUserData only supports this operation if it has a default UserData. Call addUserDataPart with makeDefault=true.';
private static readonly BOUNDRY_PATTERN = '[^a-zA-Z0-9()+,-./:=?]';

private parts: MultipartBody[] = [];

private opts: MultipartUserDataOptions;

private defaultUserData?: UserData;

constructor(opts?: MultipartUserDataOptions) {
super();

Expand Down Expand Up @@ -472,16 +474,28 @@ export class MultipartUserData extends UserData {
}

/**
* Adds a multipart part based on a UserData object
* Adds a multipart part based on a UserData object.
*
* If `makeDefault` is true, then the UserData added by this method
* will also be the target of calls to the `add*Command` methods on
* this MultipartUserData object.
*
* This is the same as calling:
* If `makeDefault` is false, then this is the same as calling:
*
* ```ts
* multiPart.addPart(MultipartBody.fromUserData(userData, contentType));
* ```
*
* An undefined `makeDefault` defaults to either:
* - `true` if no default UserData has been set yet; or
* - `false` if there is no default UserData set.
*/
public addUserDataPart(userData: UserData, contentType?: string) {
public addUserDataPart(userData: UserData, contentType?: string, makeDefault?: boolean) {
this.addPart(MultipartBody.fromUserData(userData, contentType));
makeDefault = makeDefault ?? (this.defaultUserData === undefined ? true : false);
if (makeDefault) {
this.defaultUserData = userData;
}
}

public render(): string {
Expand Down Expand Up @@ -510,23 +524,43 @@ export class MultipartUserData extends UserData {
return resultArchive.join('\n');
}

public addS3DownloadCommand(_params: S3DownloadOptions): string {
throw new Error(MultipartUserData.USE_PART_ERROR);
public addS3DownloadCommand(params: S3DownloadOptions): string {
if (this.defaultUserData) {
return this.defaultUserData.addS3DownloadCommand(params);
} else {
throw new Error(MultipartUserData.USE_PART_ERROR);
}
}

public addExecuteFileCommand(_params: ExecuteFileOptions): void {
throw new Error(MultipartUserData.USE_PART_ERROR);
public addExecuteFileCommand(params: ExecuteFileOptions): void {
if (this.defaultUserData) {
this.defaultUserData.addExecuteFileCommand(params);
} else {
throw new Error(MultipartUserData.USE_PART_ERROR);
}
}

public addSignalOnExitCommand(_resource: Resource): void {
throw new Error(MultipartUserData.USE_PART_ERROR);
public addSignalOnExitCommand(resource: Resource): void {
if (this.defaultUserData) {
this.defaultUserData.addSignalOnExitCommand(resource);
} else {
throw new Error(MultipartUserData.USE_PART_ERROR);
}
}

public addCommands(..._commands: string[]): void {
throw new Error(MultipartUserData.USE_PART_ERROR);
public addCommands(...commands: string[]): void {
if (this.defaultUserData) {
this.defaultUserData.addCommands(...commands);
} else {
throw new Error(MultipartUserData.USE_PART_ERROR);
}
}

public addOnExitCommands(..._commands: string[]): void {
throw new Error(MultipartUserData.USE_PART_ERROR);
public addOnExitCommands(...commands: string[]): void {
if (this.defaultUserData) {
this.defaultUserData.addOnExitCommands(...commands);
} else {
throw new Error(MultipartUserData.USE_PART_ERROR);
}
}
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ec2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@types/aws-lambda": "^8.10.76",
"@types/aws-lambda": "^8.10.77",
"@types/jest": "^26.0.23",
"@aws-cdk/cx-api": "0.0.0",
"cdk-build-tools": "0.0.0",
Expand Down

0 comments on commit d9ca70c

Please sign in to comment.