Skip to content

Commit

Permalink
Merge branch 'master' into epolon/node-bundle-attributions-order
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr committed Mar 18, 2022
2 parents 867749c + 3c62733 commit 9d43fe9
Show file tree
Hide file tree
Showing 25 changed files with 471 additions and 245 deletions.
191 changes: 100 additions & 91 deletions .github/workflows/issue-label-assign.yml

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,30 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.149.0](https://github.com/aws/aws-cdk/compare/v1.148.0...v1.149.0) (2022-03-17)


### Features

* **appsync:** add OpenSearch domain data source ([#16529](https://github.com/aws/aws-cdk/issues/16529)) ([922a9dc](https://github.com/aws/aws-cdk/commit/922a9dcf07174334ac67b9fcbacb01aafdfd9c6a)), closes [#16528](https://github.com/aws/aws-cdk/issues/16528)
* **assertions:** Add the `hasNoXXX` methods. ([#19330](https://github.com/aws/aws-cdk/issues/19330)) ([6bdc9eb](https://github.com/aws/aws-cdk/commit/6bdc9eb52608329f1e66c420cb6c61aa942d17b0)), closes [#18874](https://github.com/aws/aws-cdk/issues/18874)
* **aws-lambda-nodejs:** support additional esbuild configurations ([#17788](https://github.com/aws/aws-cdk/issues/17788)) ([ab313a4](https://github.com/aws/aws-cdk/commit/ab313a4abbec14a1886a7c87673dbc66354811ef))
* **cfnspec:** cloudformation spec v60.0.0 ([#19347](https://github.com/aws/aws-cdk/issues/19347)) ([20da648](https://github.com/aws/aws-cdk/commit/20da648cebddd6feaf8a54d2bf40f3ba3bd30979))
* **cli:** parallel asset publishing ([#19367](https://github.com/aws/aws-cdk/issues/19367)) ([c8cafef](https://github.com/aws/aws-cdk/commit/c8cafefc4cd98e7217973cd9eb0e92263a916b4f)), closes [#19193](https://github.com/aws/aws-cdk/issues/19193)
* **ec2:** add support for x2idn and x2iedn instances ([#19334](https://github.com/aws/aws-cdk/issues/19334)) ([9699efc](https://github.com/aws/aws-cdk/commit/9699efc0c0b0e2b265daf824147be2827555cafa))
* **elbv2:** add name validation for target group and load balancer names ([#19385](https://github.com/aws/aws-cdk/issues/19385)) ([97e0973](https://github.com/aws/aws-cdk/commit/97e09730cbb7c155e6697ace166348064d810449)), closes [/docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-targetgroup.html#cfn-elasticloadbalancingv2](https://github.com/aws//docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-targetgroup.html/issues/cfn-elasticloadbalancingv2) [/docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-loadbalancer.html#cfn-elasticloadbalancingv2](https://github.com/aws//docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-loadbalancer.html/issues/cfn-elasticloadbalancingv2)
* **iotevents:** support SetVariable action ([#19305](https://github.com/aws/aws-cdk/issues/19305)) ([c222b12](https://github.com/aws/aws-cdk/commit/c222b122206e00dc9932639efd54d78a16ebf6d3))
* **lambda:** dotnet6 runtime ([#19144](https://github.com/aws/aws-cdk/issues/19144)) ([bbed27d](https://github.com/aws/aws-cdk/commit/bbed27d95ab2724db937964d01aec5564a77e84f))
* **synthetics:** add vpc configuration ([#18447](https://github.com/aws/aws-cdk/issues/18447)) ([c991e92](https://github.com/aws/aws-cdk/commit/c991e92453034330b68daa5b5721119e770b6109)), closes [#11865](https://github.com/aws/aws-cdk/issues/11865) [#9954](https://github.com/aws/aws-cdk/issues/9954)


### Bug Fixes

* **cli:** failure to load malformed YAML is swallowed ([#19338](https://github.com/aws/aws-cdk/issues/19338)) ([1875c28](https://github.com/aws/aws-cdk/commit/1875c28865690d59c22939039a5d0e37039ab63c)), closes [#19335](https://github.com/aws/aws-cdk/issues/19335)
* **lambda-event-sources:** increase batch size restriction ([#19317](https://github.com/aws/aws-cdk/issues/19317)) ([1bc5144](https://github.com/aws/aws-cdk/commit/1bc5144b05938829f90b89001ccda8fd4aefe343)), closes [#19285](https://github.com/aws/aws-cdk/issues/19285)
* **lambda-nodejs:** cannot use esbuildArgs with older esbuild versions ([#19343](https://github.com/aws/aws-cdk/issues/19343)) ([59a4d81](https://github.com/aws/aws-cdk/commit/59a4d81cc712eedfd755232d157a2e492eb3d886))
* **stepfunctions-tasks:** migrate from deprecated batch properties ([#19298](https://github.com/aws/aws-cdk/issues/19298)) ([75f5b3b](https://github.com/aws/aws-cdk/commit/75f5b3b69abf592b2c6d0ec6c19c374754e50f97)), closes [#18993](https://github.com/aws/aws-cdk/issues/18993)

## [1.148.0](https://github.com/aws/aws-cdk/compare/v1.147.0...v1.148.0) (2022-03-09)


Expand Down
37 changes: 37 additions & 0 deletions packages/@aws-cdk/aws-appsync/README.md
Expand Up @@ -285,6 +285,43 @@ ds.createResolver({
});
```

## Custom Domain Names

For many use cases you may want to associate a custom domain name with your
GraphQL API. This can be done during the API creation.

```ts
import * as acm from '@aws-cdk/aws-certificatemanager';
import * as route53 from '@aws-cdk/aws-route53';

const myDomainName = 'api.example.com';
const certificate = new acm.Certificate(this, 'cert', { domainName: myDomainName });
const api = new appsync.GraphqlApi(this, 'api', {
name: 'myApi',
domainName: {
certificate,
domainName: myDomainName,
},
});

// hosted zone and route53 features
declare const hostedZoneId: string;
declare const zoneName = 'example.com';

// hosted zone for adding appsync domain
const zone = route53.HostedZone.fromHostedZoneAttributes(this, `HostedZone`, {
hostedZoneId,
zoneName,
});

// create a cname to the appsync domain. will map to something like xxxx.cloudfront.net
new route53.CnameRecord(this, `CnameApiRecord`, {
recordName: 'api',
zone,
domainName: myDomainName,
});
```

## Schema

Every GraphQL Api needs a schema to define the Api. CDK offers `appsync.Schema`
Expand Down
45 changes: 42 additions & 3 deletions packages/@aws-cdk/aws-appsync/lib/graphqlapi.ts
@@ -1,9 +1,10 @@
import { ICertificate } from '@aws-cdk/aws-certificatemanager';
import { IUserPool } from '@aws-cdk/aws-cognito';
import { ManagedPolicy, Role, IRole, ServicePrincipal, Grant, IGrantable } from '@aws-cdk/aws-iam';
import { IFunction } from '@aws-cdk/aws-lambda';
import { ArnFormat, CfnResource, Duration, Expiration, IResolvable, Stack } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnApiKey, CfnGraphQLApi, CfnGraphQLSchema } from './appsync.generated';
import { CfnApiKey, CfnGraphQLApi, CfnGraphQLSchema, CfnDomainName, CfnDomainNameApiAssociation } from './appsync.generated';
import { IGraphqlApi, GraphqlApiBase } from './graphqlapi-base';
import { Schema } from './schema';
import { IIntermediateType } from './schema-base';
Expand Down Expand Up @@ -254,6 +255,21 @@ export interface LogConfig {
readonly role?: IRole;
}

/**
* Domain name configuration for AppSync
*/
export interface DomainOptions {
/**
* The certificate to use with the domain name.
*/
readonly certificate: ICertificate;

/**
* The actual domain name. For example, `api.example.com`.
*/
readonly domainName: string;
}

/**
* Properties for an AppSync GraphQL API
*/
Expand Down Expand Up @@ -292,6 +308,16 @@ export interface GraphqlApiProps {
* @default - false
*/
readonly xrayEnabled?: boolean;

/**
* The domain name configuration for the GraphQL API
*
* The Route 53 hosted zone and CName DNS record must be configured in addition to this setting to
* enable custom domain URL
*
* @default - no domain name
*/
readonly domainName?: DomainOptions;
}

/**
Expand Down Expand Up @@ -391,7 +417,7 @@ export class GraphqlApi extends GraphqlApiBase {
class Import extends GraphqlApiBase {
public readonly apiId = attrs.graphqlApiId;
public readonly arn = arn;
constructor (s: Construct, i: string) {
constructor(s: Construct, i: string) {
super(s, i);
}
}
Expand Down Expand Up @@ -450,7 +476,7 @@ export class GraphqlApi extends GraphqlApiBase {
const additionalModes = props.authorizationConfig?.additionalAuthorizationModes ?? [];
const modes = [defaultMode, ...additionalModes];

this.modes = modes.map((mode) => mode.authorizationType );
this.modes = modes.map((mode) => mode.authorizationType);

this.validateAuthorizationProps(modes);

Expand All @@ -472,6 +498,19 @@ export class GraphqlApi extends GraphqlApiBase {
this.schema = props.schema ?? new Schema();
this.schemaResource = this.schema.bind(this);

if (props.domainName) {
new CfnDomainName(this, 'DomainName', {
domainName: props.domainName.domainName,
certificateArn: props.domainName.certificate.certificateArn,
description: `domain for ${this.name} at ${this.graphqlUrl}`,
});

new CfnDomainNameApiAssociation(this, 'DomainAssociation', {
domainName: props.domainName.domainName,
apiId: this.apiId,
});
}

if (modes.some((mode) => mode.authorizationType === AuthorizationType.API_KEY)) {
const config = modes.find((mode: AuthorizationMode) => {
return mode.authorizationType === AuthorizationType.API_KEY && mode.apiKeyConfig;
Expand Down
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-appsync/package.json
Expand Up @@ -89,6 +89,7 @@
"jest": "^27.5.1"
},
"dependencies": {
"@aws-cdk/aws-certificatemanager": "0.0.0",
"@aws-cdk/aws-cognito": "0.0.0",
"@aws-cdk/aws-dynamodb": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
Expand All @@ -104,6 +105,7 @@
},
"homepage": "https://github.com/aws/aws-cdk",
"peerDependencies": {
"@aws-cdk/aws-certificatemanager": "0.0.0",
"@aws-cdk/aws-cognito": "0.0.0",
"@aws-cdk/aws-dynamodb": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
Expand Down
36 changes: 36 additions & 0 deletions packages/@aws-cdk/aws-appsync/test/appsync.test.ts
@@ -1,5 +1,6 @@
import * as path from 'path';
import { Template } from '@aws-cdk/assertions';
import { Certificate } from '@aws-cdk/aws-certificatemanager';
import * as iam from '@aws-cdk/aws-iam';
import * as cdk from '@aws-cdk/core';
import * as appsync from '../lib';
Expand Down Expand Up @@ -155,3 +156,38 @@ test('appsync GraphqlApi should not use custom role for CW Logs when not specifi
},
});
});

test('appsync GraphqlApi should be configured with custom domain when specified', () => {
const domainName = 'api.example.com';
// GIVEN
const certificate = new Certificate(stack, 'AcmCertificate', {
domainName,
});

// WHEN
new appsync.GraphqlApi(stack, 'api-custom-cw-logs-role', {
authorizationConfig: {},
name: 'apiWithCustomRole',
schema: appsync.Schema.fromAsset(path.join(__dirname, 'appsync.test.graphql')),
domainName: {
domainName,
certificate,
},
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::AppSync::DomainNameApiAssociation', {
ApiId: {
'Fn::GetAtt': [
'apicustomcwlogsrole508EAC74',
'ApiId',
],
},
DomainName: domainName,
});

Template.fromStack(stack).hasResourceProperties('AWS::AppSync::DomainName', {
CertificateArn: { Ref: 'AcmCertificate49D3B5AF' },
DomainName: domainName,
});
});
15 changes: 13 additions & 2 deletions packages/@aws-cdk/aws-batch/test/integ.batch.expected.json
Expand Up @@ -1665,6 +1665,11 @@
},
"batchjobrepo4C508C51": {
"Type": "AWS::ECR::Repository",
"Properties": {
"ImageScanningConfiguration": {
"ScanOnPush": false
}
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
Expand Down Expand Up @@ -1725,8 +1730,14 @@
"Privileged": false,
"ReadonlyRootFilesystem": false,
"ResourceRequirements": [
{ "Type": "VCPU", "Value": "1" },
{ "Type": "MEMORY", "Value": "4" }
{
"Type": "VCPU",
"Value": "1"
},
{
"Type": "MEMORY",
"Value": "4"
}
]
},
"PlatformCapabilities": [
Expand Down
Expand Up @@ -2,6 +2,11 @@
"Resources": {
"MyRepoF4F48043": {
"Type": "AWS::ECR::Repository",
"Properties": {
"ImageScanningConfiguration": {
"ScanOnPush": false
}
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
Expand Down
Expand Up @@ -356,6 +356,11 @@
},
"MyEcrRepo767466D0": {
"Type": "AWS::ECR::Repository",
"Properties": {
"ImageScanningConfiguration": {
"ScanOnPush": false
}
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
Expand Down
Expand Up @@ -201,6 +201,11 @@
},
"EcrRepoBB83A592": {
"Type": "AWS::ECR::Repository",
"Properties": {
"ImageScanningConfiguration": {
"ScanOnPush": false
}
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
Expand Down
Expand Up @@ -3,6 +3,11 @@
"Resources": {
"EcsDeployRepositoryE7A569C0": {
"Type": "AWS::ECR::Repository",
"Properties": {
"ImageScanningConfiguration": {
"ScanOnPush": false
}
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
Expand Down
4 changes: 1 addition & 3 deletions packages/@aws-cdk/aws-ecr/lib/repository.ts
Expand Up @@ -508,9 +508,7 @@ export class Repository extends RepositoryBase {
// It says "Text", but they actually mean "Object".
repositoryPolicyText: Lazy.any({ produce: () => this.policyDocument }),
lifecyclePolicy: Lazy.any({ produce: () => this.renderLifecyclePolicy() }),
imageScanningConfiguration: !props.imageScanOnPush ? undefined : {
scanOnPush: true,
},
imageScanningConfiguration: props.imageScanOnPush ? { scanOnPush: true } : { scanOnPush: false },
imageTagMutability: props.imageTagMutability || undefined,
encryptionConfiguration: this.parseEncryption(props),
});
Expand Down
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-ecr/test/integ.basic.expected.json
Expand Up @@ -3,6 +3,9 @@
"Repo02AC86CF": {
"Type": "AWS::ECR::Repository",
"Properties": {
"ImageScanningConfiguration": {
"ScanOnPush": false
},
"LifecyclePolicy": {
"LifecyclePolicyText": "{\"rules\":[{\"rulePriority\":1,\"selection\":{\"tagStatus\":\"any\",\"countType\":\"imageCountMoreThan\",\"countNumber\":5},\"action\":{\"type\":\"expire\"}}]}"
}
Expand Down
5 changes: 5 additions & 0 deletions packages/@aws-cdk/aws-ecr/test/repository.test.ts
Expand Up @@ -20,6 +20,11 @@ describe('repository', () => {
Resources: {
Repo02AC86CF: {
Type: 'AWS::ECR::Repository',
Properties: {
ImageScanningConfiguration: {
ScanOnPush: false,
},
},
DeletionPolicy: 'Retain',
UpdateReplacePolicy: 'Retain',
},
Expand Down
Expand Up @@ -465,6 +465,9 @@ describe('ec2 task definition', () => {

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
ImageScanningConfiguration: {
ScanOnPush: false,
},
LifecyclePolicy: {
// eslint-disable-next-line max-len
LifecyclePolicyText: '{"rules":[{"rulePriority":10,"selection":{"tagStatus":"tagged","tagPrefixList":["abc"],"countType":"imageCountMoreThan","countNumber":1},"action":{"type":"expire"}}]}',
Expand Down Expand Up @@ -687,7 +690,11 @@ describe('ec2 task definition', () => {
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {});
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
ImageScanningConfiguration: {
ScanOnPush: false,
},
});


});
Expand Down
Expand Up @@ -356,6 +356,9 @@ describe('external task definition', () => {

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
ImageScanningConfiguration: {
ScanOnPush: false,
},
LifecyclePolicy: {
// eslint-disable-next-line max-len
LifecyclePolicyText: '{"rules":[{"rulePriority":10,"selection":{"tagStatus":"tagged","tagPrefixList":["abc"],"countType":"imageCountMoreThan","countNumber":1},"action":{"type":"expire"}}]}',
Expand Down Expand Up @@ -587,7 +590,11 @@ describe('external task definition', () => {
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {});
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
ImageScanningConfiguration: {
ScanOnPush: false,
},
});


});
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-events/lib/rule.ts
Expand Up @@ -397,7 +397,7 @@ export class Rule extends Resource implements IRule {
});
new CfnEventBusPolicy(eventBusPolicyStack, 'GivePermToOtherAccount', {
action: 'events:PutEvents',
statementId: `Allow-account-${sourceAccount}`,
statementId: `Allow-account-${sourceAccount}-${this.node.addr}`,
principal: sourceAccount,
});
}
Expand Down

0 comments on commit 9d43fe9

Please sign in to comment.