Skip to content

Commit

Permalink
Merge branch 'main' into asset_support_bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealAmazonKendra authored Jan 12, 2023
2 parents d04bf57 + 7cbe8ac commit c493ddd
Show file tree
Hide file tree
Showing 1,035 changed files with 70,144 additions and 7,925 deletions.
438 changes: 219 additions & 219 deletions .github/workflows/issue-label-assign.yml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions CHANGELOG.v2.alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

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.

## [2.60.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.59.0-alpha.0...v2.60.0-alpha.0) (2023-01-11)


### Features

* **gamelift:** add MatchmakingConfiguration L2 Construct for GameLift ([#23326](https://github.com/aws/aws-cdk/issues/23326)) ([9b2573b](https://github.com/aws/aws-cdk/commit/9b2573b32e8535d3db21f07647f099c9e01eb292))
* **integ-runner:** support `--language` presets for JavaScript, TypeScript, Python and Go ([#22058](https://github.com/aws/aws-cdk/issues/22058)) ([22673b2](https://github.com/aws/aws-cdk/commit/22673b2ea40c13b6c10a2c7c628ce5cc534f5840)), closes [#21169](https://github.com/aws/aws-cdk/issues/21169)

## [2.59.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.58.1-alpha.0...v2.59.0-alpha.0) (2023-01-03)

## [2.58.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.58.0-alpha.0...v2.58.1-alpha.0) (2022-12-30)
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.v2.md
Original file line number Diff line number Diff line change
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.

## [2.60.0](https://github.com/aws/aws-cdk/compare/v2.59.0...v2.60.0) (2023-01-11)


### Features

* **appsync:** js resolver support ([#23551](https://github.com/aws/aws-cdk/issues/23551)) ([2318384](https://github.com/aws/aws-cdk/commit/231838409cc1409c137ff27086e853ce2b0fbf1c)), closes [#22921](https://github.com/aws/aws-cdk/issues/22921)
* **appsync:** stabilize appsync module 🎆🎆 🎆 ([#23633](https://github.com/aws/aws-cdk/issues/23633)) ([e5b0230](https://github.com/aws/aws-cdk/commit/e5b023089e168c50eda83a11db0e697b96caf7e9)), closes [#6836](https://github.com/aws/aws-cdk/issues/6836)
* **cfnspec:** cloudformation spec v106.0.0 ([#23586](https://github.com/aws/aws-cdk/issues/23586)) ([f178c98](https://github.com/aws/aws-cdk/commit/f178c98d4473d8bb8d46d80c076fa520d03c623b))
* **cloudfront:** remove headers and server timing ([#23558](https://github.com/aws/aws-cdk/issues/23558)) ([44a4812](https://github.com/aws/aws-cdk/commit/44a4812778d87af27809e5a733c6e5ea6b65004b))
* **cognito:** use secretsmanager secrets for clientSecretValue ([#22885](https://github.com/aws/aws-cdk/issues/22885)) ([4baea78](https://github.com/aws/aws-cdk/commit/4baea78f415566dea499f4ce49fc24d4dc7c4ef7))
* **ec2:** subnet ipv4 cidr blocks on imported vpc ([#23317](https://github.com/aws/aws-cdk/issues/23317)) ([e0885db](https://github.com/aws/aws-cdk/commit/e0885db29c8b45cfe9da1df8b55af2bf78892a04))
* **ecr-assets:** Support docker outputs flag ([#23304](https://github.com/aws/aws-cdk/issues/23304)) ([61e5495](https://github.com/aws/aws-cdk/commit/61e5495105e06aba4c027fb33ae031da09a3ff33)), closes [#20566](https://github.com/aws/aws-cdk/issues/20566)
* **pipelines:** Expose stack output namespaces in custom `pipelines.Step`s ([#23110](https://github.com/aws/aws-cdk/issues/23110)) ([14f6811](https://github.com/aws/aws-cdk/commit/14f6811b89a0ae374863a3b2bdd36997ce67883e)), closes [/github.com/aws/aws-cdk/issues/23000#issuecomment-1324379670](https://github.com/aws//github.com/aws/aws-cdk/issues/23000/issues/issuecomment-1324379670)


### Bug Fixes

* **acm:** domainName length constraint failure due to Tokens ([#23567](https://github.com/aws/aws-cdk/issues/23567)) ([2d7e3c0](https://github.com/aws/aws-cdk/commit/2d7e3c0e9edfb8f3e30dc0c1efaeb03fde19db7c)), closes [#23565](https://github.com/aws/aws-cdk/issues/23565)
* **aws-custom-resource:** switch off `installLatestAwsSdk` by default ([#23591](https://github.com/aws/aws-cdk/issues/23591)) ([c9b2548](https://github.com/aws/aws-cdk/commit/c9b2548126f01fd918009df0a42f0ab4c5e69cc3)), closes [#23113](https://github.com/aws/aws-cdk/issues/23113)
* **bootstrap:** KMS keys cannot be tagged ([#21975](https://github.com/aws/aws-cdk/issues/21975)) ([0e552db](https://github.com/aws/aws-cdk/commit/0e552dbb63a97cd6a7a65cae80ae863609237e61)), closes [#21281](https://github.com/aws/aws-cdk/issues/21281)
* **events:** cross stack rules require concrete environment ([#23549](https://github.com/aws/aws-cdk/issues/23549)) ([22d3341](https://github.com/aws/aws-cdk/commit/22d3341c2239b046473ded3fcbc85b5cbc4a37a1)), closes [#18405](https://github.com/aws/aws-cdk/issues/18405)
* **iam:** create stack based default policies for roles ([#23100](https://github.com/aws/aws-cdk/issues/23100)) ([dea4216](https://github.com/aws/aws-cdk/commit/dea4216a3f2e6727a6bc49d632c03b3f0a416947))
* **lambda:** automatic `currentVersion` conflicts with explicit `Version` resource ([#23636](https://github.com/aws/aws-cdk/issues/23636)) ([de68652](https://github.com/aws/aws-cdk/commit/de6865229ee824c01431ae27509dbcd3e1a83763)), closes [#23225](https://github.com/aws/aws-cdk/issues/23225)

## [2.59.0](https://github.com/aws/aws-cdk/compare/v2.58.1...v2.59.0) (2023-01-03)


Expand Down
6 changes: 5 additions & 1 deletion allowed-breaking-changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,8 @@ incompatible-argument:@aws-cdk/aws-route53-targets.InterfaceVpcEndpointTarget.<i
changed-type:@aws-cdk/cx-api.AssetManifestArtifact.requiresBootstrapStackVersion

# removed mistyped ec2 instance class
removed:aws-cdk-lib.aws_ec2.InstanceClass.COMPUTE6_GRAVITON2_HIGH_NETWORK_BANDWITH
removed:aws-cdk-lib.aws_ec2.InstanceClass.COMPUTE6_GRAVITON2_HIGH_NETWORK_BANDWITH

# added new required property StackOutputsMap
strengthened:@aws-cdk/pipelines.ProduceActionOptions
strengthened:aws-cdk-lib.pipelines.ProduceActionOptions
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"devDependencies": {
"@types/prettier": "2.6.0",
"@yarnpkg/lockfile": "^1.1.0",
"cdk-generate-synthetic-examples": "^0.1.92",
"cdk-generate-synthetic-examples": "^0.1.112",
"conventional-changelog-cli": "^2.2.2",
"fs-extra": "^9.1.0",
"graceful-fs": "^4.2.10",
Expand All @@ -28,7 +28,7 @@
"jsii-reflect": "1.72.0",
"jsii-rosetta": "1.72.0",
"lerna": "^4.0.0",
"patch-package": "^6.5.0",
"patch-package": "^6.5.1",
"semver": "^6.3.0",
"standard-version": "^9.5.0",
"typescript": "~3.9.10"
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-apigateway/lib/authorizers/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export interface LambdaAuthorizerProps {
/**
* The handler for the authorizer lambda function.
*
* The handler must follow a very specific protocol on the input it receives and the output it needs to produce.
* API Gateway has documented the handler's input specification
* {@link https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-input.html | here} and output specification
* {@link https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html | here}.
* The handler must follow a very specific protocol on the input it receives
* and the output it needs to produce. API Gateway has documented the
* handler's [input specification](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-input.html)
* and [output specification](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html).
*/
readonly handler: lambda.IFunction;

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/lambda-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface LambdaRestApiProps extends RestApiProps {
/**
* Specific Lambda integration options.
*
* @default see defaults defined in {@link LambdaIntegrationOptions}.
* @default see defaults defined in `LambdaIntegrationOptions`.
*/
readonly integrationOptions?: LambdaIntegrationOptions;

Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export interface MethodOptions {
* Method authorization.
* If the value is set of `Custom`, an `authorizer` must also be specified.
*
* If you're using one of the authorizers that are available via the {@link Authorizer} class, such as {@link Authorizer#token()},
* If you're using one of the authorizers that are available via the `Authorizer` class, such as `Authorizer#token()`,
* it is recommended that this option not be specified. The authorizer will take care of setting the correct authorization type.
* However, specifying an authorization type using this property that conflicts with what is expected by the {@link Authorizer}
* However, specifying an authorization type using this property that conflicts with what is expected by the `Authorizer`
* will result in an error.
*
* @default - open access unless `authorizer` is specified
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ export abstract class RestApiBase extends Resource implements IRestApi {
/**
* Represents a REST API in Amazon API Gateway, created with an OpenAPI specification.
*
* Some properties normally accessible on @see {@link RestApi} - such as the description -
* Some properties normally accessible on @see `RestApi` - such as the description -
* must be declared in the specification. All Resources and Methods need to be defined as
* part of the OpenAPI specification file, and cannot be added via the CDK.
*
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-appmesh/lib/http-route-path-match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Construct } from 'constructs';
import { CfnGatewayRoute, CfnRoute } from './appmesh.generated';

/**
* The type returned from the `bind()` method in {@link HttpRoutePathMatch}.
* The type returned from the `bind()` method in `HttpRoutePathMatch`.
*/
export interface HttpRoutePathMatchConfig {
/**
Expand Down Expand Up @@ -94,7 +94,7 @@ class HttpRouteWholePathMatch extends HttpRoutePathMatch {
}

/**
* The type returned from the `bind()` method in {@link HttpGatewayRoutePathMatch}.
* The type returned from the `bind()` method in `HttpGatewayRoutePathMatch`.
*/
export interface HttpGatewayRoutePathMatchConfig {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-appmesh/lib/tls-certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Construct } from 'constructs';
import { CfnVirtualNode } from './appmesh.generated';

/**
* A wrapper for the tls config returned by {@link TlsCertificate.bind}
* A wrapper for the tls config returned by `TlsCertificate.bind`
*/
export interface TlsCertificateConfig {
/**
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-appsync/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ junit.xml
!**/*.snapshot/**/asset.*/*.d.ts

!**/*.snapshot/**/asset.*/**
!test/integ-assets/**/*.js
44 changes: 37 additions & 7 deletions packages/@aws-cdk/aws-appsync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@
>
> [CFN Resources]: https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib
![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)

> The APIs of higher level constructs in this module are experimental and under active development.
> They are subject to non-backward compatible changes or removal in any future version. These are
> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be
> announced in the release notes. This means that while you may use them, you may need to update
> your source code when upgrading to a newer version of this package.
![cdk-constructs: Stable](https://img.shields.io/badge/cdk--constructs-stable-success.svg?style=for-the-badge)

---

Expand Down Expand Up @@ -550,4 +544,40 @@ const pipelineResolver = new appsync.Resolver(this, 'pipeline', {
});
```

### JS Functions and Resolvers

JS Functions and resolvers are also supported. You can use a `.js` file within your CDK project, or specify your function code inline.

```ts
declare const api: appsync.GraphqlApi;

const myJsFunction = new appsync.AppsyncFunction(this, 'function', {
name: 'my_js_function',
api,
dataSource: api.addNoneDataSource('none'),
code: appsync.Code.fromAsset('directory/function_code.js'),
runtime: appsync.FunctionRuntime.JS_1_0_0,
});

new appsync.Resolver(this, 'PipelineResolver', {
api,
typeName: 'typeName',
fieldName: 'fieldName',
code: appsync.Code.fromInline(`
// The before step
export function request(...args) {
console.log(args);
return {}
}
// The after step
export function response(ctx) {
return ctx.prev.result
}
`),
runtime: appsync.FunctionRuntime.JS_1_0_0,
pipelineConfig: [myJsFunction],
});
```

Learn more about Pipeline Resolvers and AppSync Functions [here](https://docs.aws.amazon.com/appsync/latest/devguide/pipeline-resolvers.html).
28 changes: 28 additions & 0 deletions packages/@aws-cdk/aws-appsync/lib/appsync-function.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Resource, IResource, Lazy, Fn } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CfnFunctionConfiguration } from './appsync.generated';
import { Code } from './code';
import { BaseDataSource } from './data-source';
import { IGraphqlApi } from './graphqlapi-base';
import { MappingTemplate } from './mapping-template';
import { FunctionRuntime } from './runtime';

/**
* the base properties for AppSync Functions
Expand Down Expand Up @@ -31,6 +33,18 @@ export interface BaseAppsyncFunctionProps {
* @default - no response mapping template
*/
readonly responseMappingTemplate?: MappingTemplate;
/**
* The functions runtime
*
* @default - no function runtime, VTL mapping templates used
*/
readonly runtime?: FunctionRuntime;
/**
* The function code
*
* @default - no code is used
*/
readonly code?: Code;
}

/**
Expand Down Expand Up @@ -128,11 +142,25 @@ export class AppsyncFunction extends Resource implements IAppsyncFunction {

public constructor(scope: Construct, id: string, props: AppsyncFunctionProps) {
super(scope, id);

// If runtime is specified, code must also be
if (props.runtime && !props.code) {
throw new Error('Code is required when specifying a runtime');
}

if (props.code && (props.requestMappingTemplate || props.responseMappingTemplate)) {
throw new Error('Mapping templates cannot be used alongside code');
}

const code = props.code?.bind(this);
this.function = new CfnFunctionConfiguration(this, 'Resource', {
name: props.name,
description: props.description,
apiId: props.api.apiId,
dataSourceName: props.dataSource.name,
runtime: props.runtime?.toProperties(),
codeS3Location: code?.s3Location,
code: code?.inlineCode,
functionVersion: '2018-05-29',
requestMappingTemplate: props.requestMappingTemplate?.renderTemplate(),
responseMappingTemplate: props.responseMappingTemplate?.renderTemplate(),
Expand Down
98 changes: 98 additions & 0 deletions packages/@aws-cdk/aws-appsync/lib/code.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import * as s3_assets from '@aws-cdk/aws-s3-assets';
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';

/**
* Result of binding `Code` into a `Function`.
*/
export interface CodeConfig {
/**
* The location of the code in S3 (mutually exclusive with `inlineCode`.
* @default - code is not an s3 location
*/
readonly s3Location?: string;

/**
* Inline code (mutually exclusive with `s3Location`).
* @default - code is not inline code
*/
readonly inlineCode?: string;
}

/**
* Represents source code for an AppSync Function or Resolver.
*/
export abstract class Code {
/**
* Loads the function code from a local disk path.
*
* @param path The path to the source code file.
*/
public static fromAsset(path: string, options?: s3_assets.AssetOptions): AssetCode {
return new AssetCode(path, options);
}

/**
* Inline code for AppSync function
* @returns `InlineCode` with inline code.
* @param code The actual handler code (limited to 4KiB)
*/
public static fromInline(code: string): InlineCode {
return new InlineCode(code);
}

/**
* Bind source code to an AppSync Function or resolver.
*/
public abstract bind(scope: Construct): CodeConfig;
}

/**
* Represents a local file with source code used for an AppSync Function or Resolver.
*/
export class AssetCode extends Code {
private asset?: s3_assets.Asset;

/**
* @param path The path to the asset file.
*/
constructor(public readonly path: string, private readonly options: s3_assets.AssetOptions = { }) {
super();
}

public bind(scope: Construct): CodeConfig {
// If the same AssetCode is used multiple times, retain only the first instantiation.
if (!this.asset) {
this.asset = new s3_assets.Asset(scope, 'Code', {
path: this.path,
...this.options,
});
} else if (cdk.Stack.of(this.asset) !== cdk.Stack.of(scope)) {
throw new Error(`Asset is already associated with another stack '${cdk.Stack.of(this.asset).stackName}'. ` +
'Create a new Code instance for every stack.');
}

return {
s3Location: this.asset.s3ObjectUrl,
};
}
}

/**
* AppSync function code from an inline string.
*/
export class InlineCode extends Code {
constructor(private code: string) {
super();

if (code.length === 0) {
throw new Error('AppSync Inline code cannot be empty');
}
}

public bind(_scope: Construct): CodeConfig {
return {
inlineCode: this.code,
};
}
}
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-appsync/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ export * from './resolver';
export * from './schema';
export * from './graphqlapi';
export * from './graphqlapi-base';
export * from './code';
export * from './runtime';
Loading

0 comments on commit c493ddd

Please sign in to comment.