Skip to content

Commit

Permalink
Merge branch 'master' into lambda-nodejs-esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
jogold committed Nov 18, 2020
2 parents ad3a010 + 0a8971c commit c3eb7f6
Show file tree
Hide file tree
Showing 22 changed files with 95 additions and 39 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-efs/lib/efs-file-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class FileSystem extends Resource implements IFileSystem {

const filesystem = new CfnFileSystem(this, 'Resource', {
encrypted: props.encrypted,
kmsKeyId: (props.kmsKey ? props.kmsKey.keyId : undefined),
kmsKeyId: props.kmsKey?.keyArn,
lifecyclePolicies: (props.lifecyclePolicy ? [{ transitionToIa: props.lifecyclePolicy }] : undefined),
performanceMode: props.performanceMode,
throughputMode: props.throughputMode,
Expand Down
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ test('encrypted file system is created correctly with custom KMS', () => {
expectCDK(stack).to(haveResource('AWS::EFS::FileSystem', {
Encrypted: true,
KmsKeyId: {
Ref: 'customKeyFSDDB87C6D',
'Fn::GetAtt': [
'customKeyFSDDB87C6D',
'Arn',
],
},
}));
});
Expand Down
6 changes: 4 additions & 2 deletions packages/@aws-cdk/aws-iam/lib/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export class User extends Resource implements IIdentity, IUser {
public readonly userArn: string = arn;
public readonly assumeRoleAction: string = 'sts:AssumeRole';
public readonly policyFragment: PrincipalPolicyFragment = new ArnPrincipal(arn).policyFragment;
private readonly attachedPolicies = new AttachedPolicies();
private defaultPolicy?: Policy;

public addToPolicy(statement: PolicyStatement): boolean {
Expand All @@ -164,8 +165,9 @@ export class User extends Resource implements IIdentity, IUser {
throw new Error('Cannot add imported User to Group');
}

public attachInlinePolicy(_policy: Policy): void {
throw new Error('Cannot add inline policy to imported User');
public attachInlinePolicy(policy: Policy): void {
this.attachedPolicies.attach(policy);
policy.attachToUser(this);
}

public addManagedPolicy(_policy: IManagedPolicy): void {
Expand Down
60 changes: 59 additions & 1 deletion packages/@aws-cdk/aws-iam/test/user.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '@aws-cdk/assert/jest';
import { App, SecretValue, Stack } from '@aws-cdk/core';
import { ManagedPolicy, User } from '../lib';
import { ManagedPolicy, Policy, PolicyStatement, User } from '../lib';

describe('IAM user', () => {
test('default user', () => {
Expand Down Expand Up @@ -93,4 +93,62 @@ describe('IAM user', () => {
'Fn::Join': ['', ['arn:', { Ref: 'AWS::Partition' }, ':iam::', { Ref: 'AWS::AccountId' }, ':user/MyUserName']],
});
});

test('add to policy of imported user', () => {
// GIVEN
const stack = new Stack();
const user = User.fromUserName(stack, 'ImportedUser', 'john');

// WHEN
user.addToPrincipalPolicy(new PolicyStatement({
actions: ['aws:Use'],
resources: ['*'],
}));

// THEN
expect(stack).toHaveResource('AWS::IAM::Policy', {
Users: ['john'],
PolicyDocument: {
Statement: [
{
Action: 'aws:Use',
Effect: 'Allow',
Resource: '*',
},
],
Version: '2012-10-17',
},
});
});

test('attach policy to imported user', () => {
// GIVEN
const stack = new Stack();
const user = User.fromUserName(stack, 'ImportedUser', 'john');

// WHEN
user.attachInlinePolicy(new Policy(stack, 'Policy', {
statements: [
new PolicyStatement({
actions: ['aws:Use'],
resources: ['*'],
}),
],
}));

// THEN
expect(stack).toHaveResource('AWS::IAM::Policy', {
Users: ['john'],
PolicyDocument: {
Statement: [
{
Action: 'aws:Use',
Effect: 'Allow',
Resource: '*',
},
],
Version: '2012-10-17',
},
});
});
});
2 changes: 1 addition & 1 deletion packages/@aws-cdk/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"devDependencies": {
"@types/lodash": "^4.14.165",
"@types/minimatch": "^3.0.3",
"@types/node": "^10.17.44",
"@types/node": "^10.17.45",
"@types/sinon": "^9.0.8",
"cdk-build-tools": "0.0.0",
"cfn2ts": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@monocdk-experiment/assert/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"@monocdk-experiment/rewrite-imports": "0.0.0",
"@types/jest": "^26.0.15",
"@types/node": "^10.17.44",
"@types/node": "^10.17.45",
"cdk-build-tools": "0.0.0",
"constructs": "^3.2.0",
"jest": "^26.6.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/@monocdk-experiment/rewrite-imports/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"devDependencies": {
"@types/glob": "^7.1.3",
"@types/jest": "^26.0.15",
"@types/node": "^10.17.44",
"@types/node": "^10.17.45",
"cdk-build-tools": "0.0.0",
"pkglint": "0.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
"@aws-cdk/region-info": "0.0.0",
"@aws-cdk/yaml-cfn": "0.0.0",
"@types/fs-extra": "^8.1.1",
"@types/node": "^10.17.44",
"@types/node": "^10.17.45",
"cdk-build-tools": "0.0.0",
"constructs": "^3.2.0",
"fs-extra": "^9.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
"@types/jest": "^26.0.15",
"@types/minimatch": "^3.0.3",
"@types/mockery": "^1.4.29",
"@types/node": "^10.17.44",
"@types/node": "^10.17.45",
"@types/promptly": "^3.0.0",
"@types/semver": "^7.3.4",
"@types/sinon": "^9.0.8",
"@types/table": "^5.0.0",
"@types/uuid": "^8.3.0",
"@types/wrap-ansi": "^3.0.0",
"@types/yargs": "^15.0.9",
"@types/yargs": "^15.0.10",
"aws-sdk-mock": "^5.1.0",
"cdk-build-tools": "0.0.0",
"jest": "^26.6.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/awslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"devDependencies": {
"@types/fs-extra": "^8.1.1",
"@types/yargs": "^15.0.9",
"@types/yargs": "^15.0.10",
"pkglint": "0.0.0",
"typescript": "~3.9.7"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/cdk-assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"@types/jest": "^26.0.15",
"@types/jszip": "^3.4.1",
"@types/mock-fs": "^4.13.0",
"@types/node": "^10.17.44",
"@types/yargs": "^15.0.9",
"@types/node": "^10.17.45",
"@types/yargs": "^15.0.10",
"cdk-build-tools": "0.0.0",
"jest": "^26.6.3",
"jszip": "^3.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/decdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
"@types/fs-extra": "^8.1.1",
"@types/jest": "^26.0.15",
"@types/yaml": "1.9.7",
"@types/yargs": "^15.0.9",
"@types/yargs": "^15.0.10",
"jest": "^26.6.3",
"jsii": "^1.14.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/monocdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
"@aws-cdk/region-info": "0.0.0",
"@aws-cdk/yaml-cfn": "0.0.0",
"@types/fs-extra": "^8.1.1",
"@types/node": "^10.17.44",
"@types/node": "^10.17.45",
"cdk-build-tools": "0.0.0",
"constructs": "^3.2.0",
"fs-extra": "^9.0.1",
Expand Down
2 changes: 1 addition & 1 deletion tools/cdk-build-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"@types/fs-extra": "^8.1.1",
"@types/jest": "^26.0.15",
"@types/yargs": "^15.0.9",
"@types/yargs": "^15.0.10",
"pkglint": "0.0.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tools/cdk-integ-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"license": "Apache-2.0",
"devDependencies": {
"@types/fs-extra": "^8.1.1",
"@types/yargs": "^15.0.9",
"@types/yargs": "^15.0.10",
"cdk-build-tools": "0.0.0",
"pkglint": "0.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion tools/cfn2ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"devDependencies": {
"@types/fs-extra": "^8.1.1",
"@types/jest": "^26.0.15",
"@types/yargs": "^15.0.9",
"@types/yargs": "^15.0.10",
"cdk-build-tools": "0.0.0",
"jest": "^26.6.3",
"pkglint": "0.0.0"
Expand Down
2 changes: 1 addition & 1 deletion tools/eslint-plugin-cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@types/eslint": "^7.2.5",
"@types/fs-extra": "^8.1.1",
"@types/jest": "^26.0.15",
"@types/node": "^10.17.44",
"@types/node": "^10.17.45",
"eslint-plugin-rulesdir": "^0.1.0",
"jest": "^26.6.3",
"typescript": "~3.9.7"
Expand Down
2 changes: 1 addition & 1 deletion tools/nodeunit-shim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"devDependencies": {
"@types/jest": "^26.0.15",
"@types/node": "^10.17.44",
"@types/node": "^10.17.45",
"typescript": "~3.9.7"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tools/pkglint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"devDependencies": {
"@types/fs-extra": "^8.1.1",
"@types/semver": "^7.3.4",
"@types/yargs": "^15.0.9",
"@types/yargs": "^15.0.10",
"eslint-plugin-cdk": "0.0.0",
"jest": "^26.6.3",
"typescript": "~3.9.7"
Expand Down
2 changes: 1 addition & 1 deletion tools/pkgtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"license": "Apache-2.0",
"devDependencies": {
"@types/fs-extra": "^8.1.1",
"@types/yargs": "^15.0.9",
"@types/yargs": "^15.0.10",
"cdk-build-tools": "0.0.0",
"pkglint": "0.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion tools/yarn-cling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"devDependencies": {
"@types/jest": "^26.0.15",
"@types/node": "^10.17.44",
"@types/node": "^10.17.45",
"@types/yarnpkg__lockfile": "^1.1.4",
"jest": "^26.6.3",
"pkglint": "0.0.0",
Expand Down
23 changes: 8 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1661,10 +1661,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.11.2.tgz#2de1ed6670439387da1c9f549a2ade2b0a799256"
integrity sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA==

"@types/node@^10.17.44":
version "10.17.44"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.44.tgz#3945e6b702cb6403f22b779c8ea9e5c3f44ead40"
integrity sha512-vHPAyBX1ffLcy4fQHmDyIUMUb42gHZjPHU66nhvbMzAWJqHnySGZ6STwN3rwrnSd1FHB0DI/RWgGELgKSYRDmw==
"@types/node@^10.17.45":
version "10.17.45"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.45.tgz#62876db8db680f20f6114b9ae5683d74577d0c13"
integrity sha512-a+oe0zGtwRsSDynACia/z1e4gKPNnDhAV3G6GWY6ZNCzaujNCdKC7dE2JFkGHAlUhCRHgXNmWbh417bi9dEXBw==

"@types/nodeunit@^0.0.31":
version "0.0.31"
Expand Down Expand Up @@ -1761,17 +1761,10 @@
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-15.0.0.tgz#cb3f9f741869e20cce330ffbeb9271590483882d"
integrity sha512-FA/BWv8t8ZWJ+gEOnLLd8ygxH/2UFbAvgEonyfN6yWGLKc7zVjbpl2Y4CTjid9h2RfgPP6SEt6uHwEOply00yw==

"@types/yargs@^15.0.0":
version "15.0.7"
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.7.tgz#dad50a7a234a35ef9460737a56024287a3de1d2b"
integrity sha512-Gf4u3EjaPNcC9cTu4/j2oN14nSVhr8PQ+BvBcBQHAhDZfl0bVIiLgvnRXv/dn58XhTm9UXvBpvJpDlwV65QxOA==
dependencies:
"@types/yargs-parser" "*"

"@types/yargs@^15.0.9":
version "15.0.9"
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.9.tgz#524cd7998fe810cdb02f26101b699cccd156ff19"
integrity sha512-HmU8SeIRhZCWcnRskCs36Q1Q00KBV6Cqh/ora8WN1+22dY07AZdn6Gel8QZ3t26XYPImtcL8WV/eqjhVmMEw4g==
"@types/yargs@^15.0.0", "@types/yargs@^15.0.10":
version "15.0.10"
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.10.tgz#0fe3c8173a0d5c3e780b389050140c3f5ea6ea74"
integrity sha512-z8PNtlhrj7eJNLmrAivM7rjBESG6JwC5xP3RVk12i/8HVP7Xnx/sEmERnRImyEuUaJfO942X0qMOYsoupaJbZQ==
dependencies:
"@types/yargs-parser" "*"

Expand Down

0 comments on commit c3eb7f6

Please sign in to comment.