Skip to content

Commit 909f040

Browse files
authored
Merge branch 'master' into huijbers/python-monopackage-v1
2 parents 2130591 + 8d592ea commit 909f040

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2969
-570
lines changed

link-all.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ for module in ${modules}; do
2626
# according to spec (we look in the bin/ directory instead of the { "scripts"
2727
# } entry in package.json but it's quite a bit easier.
2828
if [[ -d $module/bin ]]; then
29-
for script in $(find $module/bin -perm /111); do
29+
for script in $(find $module/bin -perm +111); do
3030
echo "${script} => node_modules/.bin/$(basename $script)"
3131
ln -fs ${script} node_modules/.bin
3232
done

packages/@aws-cdk/aws-certificatemanager/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ When working with multiple domains, use the `CertificateValidation.fromDnsMultiZ
6868
const exampleCom = new route53.HostedZone(this, 'ExampleCom', {
6969
zoneName: 'example.com',
7070
});
71-
const exampleNet = new route53.HostedZone(this, 'ExampelNet', {
71+
const exampleNet = new route53.HostedZone(this, 'ExampleNet', {
7272
zoneName: 'example.net',
7373
});
7474

packages/@aws-cdk/aws-ecr/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ ecr.PublicGalleryAuthorizationToken.grantRead(user);
7474

7575
This user can then proceed to login to the registry using one of the [authentication methods](https://docs.aws.amazon.com/AmazonECR/latest/public/public-registries.html#public-registry-auth).
7676

77+
### Image tag immutability
78+
79+
You can set tag immutability on images in our repository using the `imageTagMutability` construct prop.
80+
81+
```ts
82+
new ecr.Repository(stack, 'Repo', { imageTagMutability: ecr.TagMutability.IMMUTABLE });
83+
```
84+
7785
## Automatically clean up repositories
7886

7987
You can set life cycle rules to automatically clean up old images from your

packages/@aws-cdk/aws-ecr/lib/repository.ts

+24
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,13 @@ export interface RepositoryProps {
354354
* @default false
355355
*/
356356
readonly imageScanOnPush?: boolean;
357+
358+
/**
359+
* The tag mutability setting for the repository. If this parameter is omitted, the default setting of MUTABLE will be used which will allow image tags to be overwritten.
360+
*
361+
* @default TagMutability.MUTABLE
362+
*/
363+
readonly imageTagMutability?: TagMutability;
357364
}
358365

359366
export interface RepositoryAttributes {
@@ -452,6 +459,7 @@ export class Repository extends RepositoryBase {
452459
imageScanningConfiguration: !props.imageScanOnPush ? undefined : {
453460
ScanOnPush: true,
454461
},
462+
imageTagMutability: props.imageTagMutability || undefined,
455463
});
456464

457465
resource.applyRemovalPolicy(props.removalPolicy);
@@ -610,3 +618,19 @@ const enum CountType {
610618
*/
611619
SINCE_IMAGE_PUSHED = 'sinceImagePushed',
612620
}
621+
622+
/**
623+
* The tag mutability setting for your repository.
624+
*/
625+
export enum TagMutability {
626+
/**
627+
* allow image tags to be overwritten.
628+
*/
629+
MUTABLE = 'MUTABLE',
630+
631+
/**
632+
* all image tags within the repository will be immutable which will prevent them from being overwritten.
633+
*/
634+
IMMUTABLE = 'IMMUTABLE',
635+
636+
}

packages/@aws-cdk/aws-ecr/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
"import:@aws-cdk/aws-ecr.Repository",
104104
"construct-base-is-private:@aws-cdk/aws-ecr.RepositoryBase",
105105
"docs-public-apis:@aws-cdk/aws-ecr.Repository.fromRepositoryArn",
106+
"docs-public-apis:@aws-cdk/aws-ecr.Repository.imageTagMutability",
106107
"docs-public-apis:@aws-cdk/aws-ecr.Repository.fromRepositoryName",
107108
"props-default-doc:@aws-cdk/aws-ecr.LifecycleRule.maxImageAge",
108109
"props-default-doc:@aws-cdk/aws-ecr.LifecycleRule.maxImageCount",

packages/@aws-cdk/aws-ecr/test/test.repository.ts

+14
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@ export = {
6363
test.done();
6464
},
6565

66+
67+
'image tag mutability can be set'(test: Test) {
68+
// GIVEN
69+
const stack = new cdk.Stack();
70+
new ecr.Repository(stack, 'Repo', { imageTagMutability: ecr.TagMutability.IMMUTABLE });
71+
72+
// THEN
73+
expect(stack).to(haveResource('AWS::ECR::Repository', {
74+
ImageTagMutability: 'IMMUTABLE',
75+
}));
76+
77+
test.done();
78+
},
79+
6680
'add day-based lifecycle policy'(test: Test) {
6781
// GIVEN
6882
const stack = new cdk.Stack();

packages/@aws-cdk/aws-ecs/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,20 @@ new ecs.Ec2Service(stack, 'Service', {
728728
});
729729
```
730730

731+
### Associate With a Specific CloudMap Service
732+
733+
You may associate an ECS service with a specific CloudMap service. To do
734+
this, use the service's `associateCloudMapService` method:
735+
736+
```ts
737+
const cloudMapService = new cloudmap.Service(...);
738+
const ecsService = new ecs.FargateService(...);
739+
740+
ecsService.associateCloudMapService({
741+
service: cloudMapService,
742+
});
743+
```
744+
731745
## Capacity Providers
732746

733747
Currently, only `FARGATE` and `FARGATE_SPOT` capacity providers are supported.

packages/@aws-cdk/aws-ecs/lib/base/base-service.ts

+47
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,27 @@ export abstract class BaseService extends Resource
601601
return cloudmapService;
602602
}
603603

604+
/**
605+
* Associates this service with a CloudMap service
606+
*/
607+
public associateCloudMapService(options: AssociateCloudMapServiceOptions): void {
608+
const service = options.service;
609+
610+
const { containerName, containerPort } = determineContainerNameAndPort({
611+
taskDefinition: this.taskDefinition,
612+
dnsRecordType: service.dnsRecordType,
613+
container: options.container,
614+
containerPort: options.containerPort,
615+
});
616+
617+
// add Cloudmap service to the ECS Service's serviceRegistry
618+
this.addServiceRegistry({
619+
arn: service.serviceArn,
620+
containerName,
621+
containerPort,
622+
});
623+
}
624+
604625
/**
605626
* This method returns the specified CloudWatch metric name for this service.
606627
*/
@@ -748,6 +769,10 @@ export abstract class BaseService extends Resource
748769
* Associate Service Discovery (Cloud Map) service
749770
*/
750771
private addServiceRegistry(registry: ServiceRegistry) {
772+
if (this.serviceRegistries.length >= 1) {
773+
throw new Error('Cannot associate with the given service discovery registry. ECS supports at most one service registry per service.');
774+
}
775+
751776
const sr = this.renderServiceRegistry(registry);
752777
this.serviceRegistries.push(sr);
753778
}
@@ -816,6 +841,28 @@ export interface CloudMapOptions {
816841
readonly containerPort?: number;
817842
}
818843

844+
/**
845+
* The options for using a cloudmap service.
846+
*/
847+
export interface AssociateCloudMapServiceOptions {
848+
/**
849+
* The cloudmap service to register with.
850+
*/
851+
readonly service: cloudmap.IService;
852+
853+
/**
854+
* The container to point to for a SRV record.
855+
* @default - the task definition's default container
856+
*/
857+
readonly container?: ContainerDefinition;
858+
859+
/**
860+
* The port to point to for a SRV record.
861+
* @default - the default port of the task definition's default container
862+
*/
863+
readonly containerPort?: number;
864+
}
865+
819866
/**
820867
* Service Registry for ECS service
821868
*/

packages/@aws-cdk/aws-ecs/test/fargate/fargate-service.test.ts

+95
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,101 @@ nodeunitShim({
262262
test.done();
263263
},
264264

265+
'with user-provided cloudmap service'(test: Test) {
266+
// GIVEN
267+
const stack = new cdk.Stack();
268+
const vpc = new ec2.Vpc(stack, 'MyVpc', {});
269+
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
270+
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'FargateTaskDef');
271+
272+
const container = taskDefinition.addContainer('web', {
273+
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
274+
memoryLimitMiB: 512,
275+
});
276+
container.addPortMappings({ containerPort: 8000 });
277+
278+
const cloudMapNamespace = new cloudmap.PrivateDnsNamespace(stack, 'TestCloudMapNamespace', {
279+
name: 'scorekeep.com',
280+
vpc,
281+
});
282+
283+
const cloudMapService = new cloudmap.Service(stack, 'Service', {
284+
name: 'service-name',
285+
namespace: cloudMapNamespace,
286+
dnsRecordType: cloudmap.DnsRecordType.SRV,
287+
});
288+
289+
const ecsService = new ecs.FargateService(stack, 'FargateService', {
290+
cluster,
291+
taskDefinition,
292+
});
293+
294+
// WHEN
295+
ecsService.associateCloudMapService({
296+
service: cloudMapService,
297+
container: container,
298+
containerPort: 8000,
299+
});
300+
301+
// THEN
302+
expect(stack).to(haveResource('AWS::ECS::Service', {
303+
ServiceRegistries: [
304+
{
305+
ContainerName: 'web',
306+
ContainerPort: 8000,
307+
RegistryArn: { 'Fn::GetAtt': ['ServiceDBC79909', 'Arn'] },
308+
},
309+
],
310+
}));
311+
312+
test.done();
313+
},
314+
315+
'errors when more than one service registry used'(test: Test) {
316+
// GIVEN
317+
const stack = new cdk.Stack();
318+
const vpc = new ec2.Vpc(stack, 'MyVpc', {});
319+
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
320+
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'FargateTaskDef');
321+
322+
const container = taskDefinition.addContainer('web', {
323+
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
324+
memoryLimitMiB: 512,
325+
});
326+
container.addPortMappings({ containerPort: 8000 });
327+
328+
const cloudMapNamespace = new cloudmap.PrivateDnsNamespace(stack, 'TestCloudMapNamespace', {
329+
name: 'scorekeep.com',
330+
vpc,
331+
});
332+
333+
const ecsService = new ecs.FargateService(stack, 'FargateService', {
334+
cluster,
335+
taskDefinition,
336+
});
337+
338+
ecsService.enableCloudMap({
339+
cloudMapNamespace,
340+
});
341+
342+
const cloudMapService = new cloudmap.Service(stack, 'Service', {
343+
name: 'service-name',
344+
namespace: cloudMapNamespace,
345+
dnsRecordType: cloudmap.DnsRecordType.SRV,
346+
});
347+
348+
// WHEN / THEN
349+
test.throws(() => {
350+
ecsService.associateCloudMapService({
351+
service: cloudMapService,
352+
container: container,
353+
containerPort: 8000,
354+
});
355+
}, /at most one service registry/i);
356+
357+
test.done();
358+
},
359+
265360
'with all properties set'(test: Test) {
266361
// GIVEN
267362
const stack = new cdk.Stack();

packages/@aws-cdk/aws-elasticloadbalancingv2/lib/alb/application-listener.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,7 @@ export class ApplicationListener extends BaseListener implements IApplicationLis
266266
// Only one certificate can be specified per resource, even though
267267
// `certificates` is of type Array
268268
for (let i = 0; i < additionalCerts.length; i++) {
269-
// ids should look like: `id`, `id2`, `id3` (for backwards-compatibility)
270-
const certId = (i > 0) ? `${id}${i + 1}` : id;
271-
new ApplicationListenerCertificate(this, certId, {
269+
new ApplicationListenerCertificate(this, `${id}${i + 1}`, {
272270
listener: this,
273271
certificates: [additionalCerts[i]],
274272
});

packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/listener.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ describe('tests', () => {
162162
],
163163
});
164164

165-
expect(listener.node.tryFindChild('DefaultCertificates')).toBeDefined();
165+
expect(listener.node.tryFindChild('DefaultCertificates1')).toBeDefined();
166166
expect(listener.node.tryFindChild('DefaultCertificates2')).toBeDefined();
167167
expect(listener.node.tryFindChild('DefaultCertificates3')).not.toBeDefined();
168168

packages/@aws-cdk/aws-iam/lib/policy-statement.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ export class PolicyStatement {
6464
constructor(props: PolicyStatementProps = {}) {
6565
// Validate actions
6666
for (const action of [...props.actions || [], ...props.notActions || []]) {
67-
if (!/^(\*|[a-zA-Z0-9-]+:[a-zA-Z0-9*]+)$/.test(action)) {
67+
68+
if (!/^(\*|[a-zA-Z0-9-]+:[a-zA-Z0-9*]+)$/.test(action) && !cdk.Token.isUnresolved(action)) {
6869
throw new Error(`Action '${action}' is invalid. An action string consists of a service namespace, a colon, and the name of an action. Action names can include wildcards.`);
6970
}
7071
}

packages/@aws-cdk/aws-iam/test/policy-document.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,19 @@ describe('IAM policy document', () => {
102102
}).toThrow(/Action 'in:val:id' is invalid/);
103103
});
104104

105+
// https://github.com/aws/aws-cdk/issues/13479
106+
test('Does not validate unresolved tokens', () => {
107+
const stack = new Stack();
108+
const perm = new PolicyStatement({
109+
actions: [`${Lazy.string({ produce: () => 'sqs:sendMessage' })}`],
110+
});
111+
112+
expect(stack.resolve(perm.toStatementJson())).toEqual({
113+
Effect: 'Allow',
114+
Action: 'sqs:sendMessage',
115+
});
116+
});
117+
105118
test('Cannot combine Resources and NotResources', () => {
106119
expect(() => {
107120
new PolicyStatement({

packages/@aws-cdk/aws-neptune/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ versions and limitations.
6767
The following example shows enabling IAM authentication for a database cluster and granting connection access to an IAM role.
6868

6969
```ts
70-
const cluster = new rds.DatabaseCluster(stack, 'Cluster', {
70+
const cluster = new neptune.DatabaseCluster(this, 'Cluster', {
7171
vpc,
7272
instanceType: neptune.InstanceType.R5_LARGE,
7373
iamAuthentication: true, // Optional - will be automatically set if you call grantConnect().
7474
});
75-
const role = new Role(stack, 'DBRole', { assumedBy: new AccountPrincipal(stack.account) });
76-
instance.grantConnect(role); // Grant the role connection access to the DB.
75+
const role = new iam.Role(this, 'DBRole', { assumedBy: new iam.AccountPrincipal(this.account) });
76+
cluster.grantConnect(role); // Grant the role connection access to the DB.
7777
```
7878

7979
## Customizing parameters

packages/@aws-cdk/aws-neptune/rosetta/default.ts-fixture

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Duration, Stack } from '@aws-cdk/core';
22
import { Construct } from 'constructs';
3+
import * as iam from '@aws-cdk/aws-iam';
34
import * as ec2 from '@aws-cdk/aws-ec2';
45
import * as neptune from '@aws-cdk/aws-neptune';
56

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const baseConfig = require('cdk-build-tools/config/eslintrc');
2+
baseConfig.parserOptions.project = __dirname + '/tsconfig.json';
3+
module.exports = baseConfig;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
*.js
2+
*.js.map
3+
*.d.ts
4+
tsconfig.json
5+
node_modules
6+
*.generated.ts
7+
dist
8+
.jsii
9+
10+
.LAST_BUILD
11+
.nyc_output
12+
coverage
13+
.nycrc
14+
.LAST_PACKAGE
15+
*.snk
16+
nyc.config.js
17+
!.eslintrc.js
18+
!jest.config.js
19+
junit.xml

0 commit comments

Comments
 (0)