Skip to content

Commit 287f771

Browse files
authored
Merge branch 'master' into csumpter/synthetics-fix-getbucketlocation
2 parents 54853fe + 0e08eeb commit 287f771

File tree

52 files changed

+3067
-2016
lines changed

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

+3067
-2016
lines changed

Diff for: CHANGELOG.md

+55
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,61 @@
22

33
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.
44

5+
## [1.140.0](https://github.com/aws/aws-cdk/compare/v1.139.0...v1.140.0) (2022-01-20)
6+
7+
8+
### ⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES
9+
10+
* **apigatewayv2:** `HttpIntegrationType.LAMBDA_PROXY` has been renamed to `HttpIntegrationType.AWS_PROXY`
11+
* **iot:** the class `FirehoseStreamAction` has been renamed to `FirehosePutRecordAction`
12+
13+
### Features
14+
15+
* **apigatewayv2:** HttpRouteIntegration supports AWS services integrations ([#18154](https://github.com/aws/aws-cdk/issues/18154)) ([a8094c7](https://github.com/aws/aws-cdk/commit/a8094c7d9970557077f560ccd24882216094ee3c)), closes [#16287](https://github.com/aws/aws-cdk/issues/16287)
16+
* **apigatewayv2:** support for mock integration type ([#18129](https://github.com/aws/aws-cdk/issues/18129)) ([7779c14](https://github.com/aws/aws-cdk/commit/7779c147c7445d9e8ccafa9b732521c9021a6234)), closes [#15008](https://github.com/aws/aws-cdk/issues/15008)
17+
* **apigatewayv2:** websocket api: api keys ([#16636](https://github.com/aws/aws-cdk/issues/16636)) ([24f8f74](https://github.com/aws/aws-cdk/commit/24f8f74ebec023f5e3f5bd2bdfc89575a53b38f3))
18+
* **assertions:** `stringLikeRegexp()` matcher ([#18491](https://github.com/aws/aws-cdk/issues/18491)) ([b49b002](https://github.com/aws/aws-cdk/commit/b49b002e40f5b901935f52827f417bb3851badc2))
19+
* **assertions:** support for parameters ([#18469](https://github.com/aws/aws-cdk/issues/18469)) ([d0d6fc5](https://github.com/aws/aws-cdk/commit/d0d6fc520491351b44cac78aa90284c82a9499b2)), closes [#16720](https://github.com/aws/aws-cdk/issues/16720)
20+
* **aws-neptune:** add autoMinorVersionUpgrade to cluster props ([#18394](https://github.com/aws/aws-cdk/issues/18394)) ([8b5320a](https://github.com/aws/aws-cdk/commit/8b5320ac5e5c320db46bc74f33b3841977dd3a5d)), closes [#17545](https://github.com/aws/aws-cdk/issues/17545)
21+
* **aws-s3:** support number of newer versions to retain in lifecycle policy ([#18225](https://github.com/aws/aws-cdk/issues/18225)) ([e1731b1](https://github.com/aws/aws-cdk/commit/e1731b11c9417a9a4d6cf0f2089c62a721e8d074)), closes [#17996](https://github.com/aws/aws-cdk/issues/17996) [#17996](https://github.com/aws/aws-cdk/issues/17996)
22+
* **cfnspec:** cloudformation spec v53.0.0 ([#18468](https://github.com/aws/aws-cdk/issues/18468)) ([50637e0](https://github.com/aws/aws-cdk/commit/50637e08590c2051d9a1e446ee7ded47e85d02b3))
23+
* **cfnspec:** cloudformation spec v53.0.0 ([#18480](https://github.com/aws/aws-cdk/issues/18480)) ([38e1fe4](https://github.com/aws/aws-cdk/commit/38e1fe42d8b30d6afaf4a3ccc90dd15d6a5d8255))
24+
* **cfnspec:** cloudformation spec v53.0.0 ([#18524](https://github.com/aws/aws-cdk/issues/18524)) ([517d517](https://github.com/aws/aws-cdk/commit/517d517a0bb3f7f6e98538dca736086b86b206c8))
25+
* **cfnspec:** cloudformation spec v53.0.0 ([#18551](https://github.com/aws/aws-cdk/issues/18551)) ([926310b](https://github.com/aws/aws-cdk/commit/926310bace65a763972d56c0df5730cdc44f8f82))
26+
* **cli:** support hotswapping Lambda functions that use Docker images ([#18319](https://github.com/aws/aws-cdk/issues/18319)) ([6b553b7](https://github.com/aws/aws-cdk/commit/6b553b7f84e5cde8a1fc533af95ad440c020e834)), closes [#18302](https://github.com/aws/aws-cdk/issues/18302) [#18408](https://github.com/aws/aws-cdk/issues/18408)
27+
* **cli:** support hotswapping Lambda functions with inline code ([#18408](https://github.com/aws/aws-cdk/issues/18408)) ([d0b8512](https://github.com/aws/aws-cdk/commit/d0b8512449759bf74bb53aabbb6d5224b5f8c5ae)), closes [#18319](https://github.com/aws/aws-cdk/issues/18319)
28+
* **cli:** watch streams resources' CloudWatch logs to the terminal ([#18159](https://github.com/aws/aws-cdk/issues/18159)) ([a9038ae](https://github.com/aws/aws-cdk/commit/a9038ae9c7d9b15b89ae24cfa24aefa6012674bc)), closes [#18122](https://github.com/aws/aws-cdk/issues/18122)
29+
* **cognito:** identity pools ([#16190](https://github.com/aws/aws-cdk/issues/16190)) ([59fe395](https://github.com/aws/aws-cdk/commit/59fe395a5adcd35bd59c6d9c74f4a2606aec88b0))
30+
* **ec2:** add Hpc6a instances ([#18445](https://github.com/aws/aws-cdk/issues/18445)) ([c7f39ca](https://github.com/aws/aws-cdk/commit/c7f39ca97874c1d8d5286ab347a97fc458547830))
31+
* **ec2:** add support for al2022 and amzn2 with kernel 5.x ([#18117](https://github.com/aws/aws-cdk/issues/18117)) ([6b73d1d](https://github.com/aws/aws-cdk/commit/6b73d1d3d0ac05042c1e43a64068938138fe8421))
32+
* **ec2:** create Peers via security group ids ([#18248](https://github.com/aws/aws-cdk/issues/18248)) ([9d1b2c7](https://github.com/aws/aws-cdk/commit/9d1b2c7b1f0147089f912c32a61d7ba86edb543c)), closes [#7111](https://github.com/aws/aws-cdk/issues/7111)
33+
* **ecs-service-extensions:** Enable default logging to CloudWatch for extensions (under feature flag) ([#17817](https://github.com/aws/aws-cdk/issues/17817)) ([06666f4](https://github.com/aws/aws-cdk/commit/06666f4727b9745d001bc20f027b535538bb8250))
34+
* **iot:** add Action to put record to Kinesis Data stream ([#18321](https://github.com/aws/aws-cdk/issues/18321)) ([1480213](https://github.com/aws/aws-cdk/commit/1480213a032549ab7319e0c3a66e02e9b6a9c4ab)), closes [#17703](https://github.com/aws/aws-cdk/issues/17703)
35+
* **lambda-nodejs:** ES modules ([#18346](https://github.com/aws/aws-cdk/issues/18346)) ([e23b63f](https://github.com/aws/aws-cdk/commit/e23b63fc106c4781e3dd39a16d4a3e3c81bdd874)), closes [#13274](https://github.com/aws/aws-cdk/issues/13274)
36+
* **opensearch:** added opensearch 1.1 to engineversion ([#18432](https://github.com/aws/aws-cdk/issues/18432)) ([e01a57a](https://github.com/aws/aws-cdk/commit/e01a57aa3085a8282123afbc3583b1b78a075c9a)), closes [#18431](https://github.com/aws/aws-cdk/issues/18431)
37+
38+
39+
### Bug Fixes
40+
41+
* **apigateway:** `enabled` property of `ApiKeyProps` is ignored ([#18407](https://github.com/aws/aws-cdk/issues/18407)) ([c31f9b4](https://github.com/aws/aws-cdk/commit/c31f9b44165f872f8dd51605e00f4801ed611d4d))
42+
* **applicationautoscaling:** typo in `DYANMODB_WRITE_CAPACITY_UTILIZATION` ([#18085](https://github.com/aws/aws-cdk/issues/18085)) ([626e6aa](https://github.com/aws/aws-cdk/commit/626e6aa1a27feffe7ce60a46a6fdcf26f317eaef)), closes [#17209](https://github.com/aws/aws-cdk/issues/17209)
43+
* **assertions:** object partiality is dropped passing through arrays ([#18525](https://github.com/aws/aws-cdk/issues/18525)) ([eb29e6f](https://github.com/aws/aws-cdk/commit/eb29e6ff0308eb320ec772cc35cdbf781168198e))
44+
* **cli:** `cdk watch` constantly prints 'messages suppressed' ([#18486](https://github.com/aws/aws-cdk/issues/18486)) ([9b266f4](https://github.com/aws/aws-cdk/commit/9b266f49643d058709771892f908f1c2ae248f95)), closes [#18451](https://github.com/aws/aws-cdk/issues/18451)
45+
* **cli:** warning to upgrade to bootstrap version >= undefined ([#18489](https://github.com/aws/aws-cdk/issues/18489)) ([da5a305](https://github.com/aws/aws-cdk/commit/da5a305875f0b82b896861be3fcb12fddaa0cc7b))
46+
* **ec2:** interface endpoints do not work with `Vpc.fromLookup()` ([#18554](https://github.com/aws/aws-cdk/issues/18554)) ([f55cd2b](https://github.com/aws/aws-cdk/commit/f55cd2bd86405cc61d3eb24c2b827c2cd133363d)), closes [#17600](https://github.com/aws/aws-cdk/issues/17600)
47+
* **ec2:** launch template names in imdsv2 not unique across stacks (under feature flag) ([#17766](https://github.com/aws/aws-cdk/issues/17766)) ([2a80e4b](https://github.com/aws/aws-cdk/commit/2a80e4b113bac0716f5aa1d4806e425759da1743))
48+
* **ecs:** respect LogGroup's region for aws-log-driver ([#18212](https://github.com/aws/aws-cdk/issues/18212)) ([b6e3e51](https://github.com/aws/aws-cdk/commit/b6e3e517ac42b7951bc4ca4c1fd62422e3b49092)), closes [#17747](https://github.com/aws/aws-cdk/issues/17747)
49+
* **elbv2:** BaseLoadBalancer.vpc is not optional ([#18474](https://github.com/aws/aws-cdk/issues/18474)) ([f511c17](https://github.com/aws/aws-cdk/commit/f511c17aac8ca4d3fa94ace051d9946dc23f40a3)), closes [aws/jsii#3342](https://github.com/aws/jsii/issues/3342)
50+
* **iot:** `FirehoseStreamAction` is now called `FirehosePutRecordAction` ([#18356](https://github.com/aws/aws-cdk/issues/18356)) ([c016a9f](https://github.com/aws/aws-cdk/commit/c016a9fcf51f2415e6e0fcca2255da384c8abbc1)), closes [/github.com/aws/aws-cdk/pull/18321#discussion_r781620195](https://github.com/aws//github.com/aws/aws-cdk/pull/18321/issues/discussion_r781620195)
51+
* **pipelines:** "Maximum schema version supported" error ([#18404](https://github.com/aws/aws-cdk/issues/18404)) ([a684ff4](https://github.com/aws/aws-cdk/commit/a684ff47d56038a94c82cdbad9588da939963351)), closes [#18370](https://github.com/aws/aws-cdk/issues/18370)
52+
* **pipelines:** graphnode dependencies can have duplicates ([#18450](https://github.com/aws/aws-cdk/issues/18450)) ([2b0b5ea](https://github.com/aws/aws-cdk/commit/2b0b5ea5db7ce8103a641c1267b1c213453ac145))
53+
* **secretsmanager:** Secret requires KMS key for some same-account access ([#17812](https://github.com/aws/aws-cdk/issues/17812)) ([91f3539](https://github.com/aws/aws-cdk/commit/91f3539f4aa8383adcb2273790ddb469fb1274a6)), closes [#15450](https://github.com/aws/aws-cdk/issues/15450)
54+
55+
56+
### Reverts
57+
58+
* **s3:** add EventBridge bucket notifications ([#18150](https://github.com/aws/aws-cdk/issues/18150)) ([#18507](https://github.com/aws/aws-cdk/issues/18507)) ([2041278](https://github.com/aws/aws-cdk/commit/204127862d5fb1d2e6dd573a1621254e52eca4aa))
59+
560
## [1.139.0](https://github.com/aws/aws-cdk/compare/v1.138.2...v1.139.0) (2022-01-11)
661

762

Diff for: packages/@aws-cdk/assertions/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ expect(result.Foo).toEqual({ Value: 'Fred', Description: 'FooFred' });
139139
expect(result.Bar).toEqual({ Value: 'Fred', Description: 'BarFred' });
140140
```
141141

142-
The APIs `hasMapping()` and `findMappings()` provide similar functionalities.
142+
The APIs `hasMapping()`, `findMappings()`, `hasCondition()`, and `hasCondtions()` provide similar functionalities.
143143

144144
## Special Matchers
145145

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { filterLogicalId, formatFailure, matchSection } from './section';
2+
import { Template } from './template';
3+
4+
export function findConditions(template: Template, logicalId: string, props: any = {}): { [key: string]: { [key: string]: any } } {
5+
const section: { [key: string] : {} } = template.Conditions;
6+
const result = matchSection(filterLogicalId(section, logicalId), props);
7+
8+
if (!result.match) {
9+
return {};
10+
}
11+
12+
return result.matches;
13+
}
14+
15+
export function hasCondition(template: Template, logicalId: string, props: any): string | void {
16+
const section: { [key: string] : {} } = template.Conditions;
17+
const result = matchSection(filterLogicalId(section, logicalId), props);
18+
if (result.match) {
19+
return;
20+
}
21+
22+
if (result.closestResult === undefined) {
23+
return 'No conditions found in the template';
24+
}
25+
26+
return [
27+
`Template has ${result.analyzedCount} conditions, but none match as expected.`,
28+
formatFailure(result.closestResult),
29+
].join('\n');
30+
}

Diff for: packages/@aws-cdk/assertions/lib/private/template.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export type Template = {
44
Resources: { [logicalId: string]: Resource },
55
Outputs: { [logicalId: string]: Output },
66
Mappings: { [logicalId: string]: Mapping },
7-
Parameters: { [logicalId: string]: Parameter }
7+
Parameters: { [logicalId: string]: Parameter },
8+
Conditions: { [logicalId: string]: Condition },
89
}
910

1011
export type Resource = {
@@ -19,4 +20,6 @@ export type Mapping = { [key: string]: any };
1920
export type Parameter = {
2021
Type: string;
2122
[key: string]: any;
22-
}
23+
}
24+
25+
export type Condition = { [key: string]: any };

Diff for: packages/@aws-cdk/assertions/lib/template.ts

+26
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Stack, Stage } from '@aws-cdk/core';
33
import * as fs from 'fs-extra';
44
import { Match } from './match';
55
import { Matcher } from './matcher';
6+
import { findConditions, hasCondition } from './private/conditions';
67
import { findMappings, hasMapping } from './private/mappings';
78
import { findOutputs, hasOutput } from './private/outputs';
89
import { findParameters, hasParameter } from './private/parameters';
@@ -183,6 +184,31 @@ export class Template {
183184
return findMappings(this.template, logicalId, props);
184185
}
185186

187+
/**
188+
* Assert that a Condition with the given properties exists in the CloudFormation template.
189+
* By default, performs partial matching on the resource, via the `Match.objectLike()`.
190+
* To configure different behavour, use other matchers in the `Match` class.
191+
* @param logicalId the name of the mapping. Provide `'*'` to match all conditions in the template.
192+
* @param props the output as should be expected in the template.
193+
*/
194+
public hasCondition(logicalId: string, props: any): void {
195+
const matchError = hasCondition(this.template, logicalId, props);
196+
if (matchError) {
197+
throw new Error(matchError);
198+
}
199+
}
200+
201+
/**
202+
* Get the set of matching Conditions that match the given properties in the CloudFormation template.
203+
* @param logicalId the name of the condition. Provide `'*'` to match all conditions in the template.
204+
* @param props by default, matches all Conditions in the template.
205+
* When a literal object is provided, performs a partial match via `Match.objectLike()`.
206+
* Use the `Match` APIs to configure a different behaviour.
207+
*/
208+
public findConditions(logicalId: string, props: any = {}): { [key: string]: { [key: string]: any } } {
209+
return findConditions(this.template, logicalId, props);
210+
}
211+
186212
/**
187213
* Assert that the CloudFormation template matches the given value
188214
* @param expected the expected CloudFormation template as key-value pairs.

Diff for: packages/@aws-cdk/assertions/test/template.test.ts

+145-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { App, CfnMapping, CfnOutput, CfnParameter, CfnResource, NestedStack, Stack } from '@aws-cdk/core';
1+
import { App, CfnCondition, CfnMapping, CfnOutput, CfnParameter, CfnResource, Fn, NestedStack, Stack } from '@aws-cdk/core';
22
import { Construct } from 'constructs';
33
import { Capture, Match, Template } from '../lib';
44

@@ -940,6 +940,150 @@ describe('Template', () => {
940940
expect(Object.keys(result).length).toEqual(0);
941941
});
942942
});
943+
944+
describe('hasCondition', () => {
945+
test('matching', () => {
946+
const stack = new Stack();
947+
new CfnCondition(stack, 'Foo', {
948+
expression: Fn.conditionEquals('Bar', 'Baz'),
949+
});
950+
951+
const inspect = Template.fromStack(stack);
952+
expect(() => inspect.hasCondition('*', { 'Fn::Equals': ['Bar', 'Baz'] })).not.toThrow();
953+
});
954+
955+
test('not matching', (done) => {
956+
const stack = new Stack();
957+
new CfnCondition(stack, 'Foo', {
958+
expression: Fn.conditionEquals('Bar', 'Baz'),
959+
});
960+
961+
new CfnCondition(stack, 'Qux', {
962+
expression: Fn.conditionNot(Fn.conditionEquals('Quux', 'Quuz')),
963+
});
964+
965+
const inspect = Template.fromStack(stack);
966+
expectToThrow(
967+
() => inspect.hasCondition('*', {
968+
'Fn::Equals': ['Baz', 'Bar'],
969+
}),
970+
[
971+
/2 conditions/,
972+
/Missing key/,
973+
],
974+
done,
975+
);
976+
done();
977+
});
978+
979+
test('matching specific outputName', () => {
980+
const stack = new Stack();
981+
new CfnCondition(stack, 'Foo', {
982+
expression: Fn.conditionEquals('Bar', 'Baz'),
983+
});
984+
985+
const inspect = Template.fromStack(stack);
986+
expect(() => inspect.hasCondition('Foo', { 'Fn::Equals': ['Bar', 'Baz'] })).not.toThrow();
987+
});
988+
989+
test('not matching specific outputName', (done) => {
990+
const stack = new Stack();
991+
new CfnCondition(stack, 'Foo', {
992+
expression: Fn.conditionEquals('Baz', 'Bar'),
993+
});
994+
995+
const inspect = Template.fromStack(stack);
996+
expectToThrow(
997+
() => inspect.hasCondition('Foo', {
998+
'Fn::Equals': ['Bar', 'Baz'],
999+
}),
1000+
[
1001+
/1 conditions/,
1002+
/Expected Baz but received Bar/,
1003+
],
1004+
done,
1005+
);
1006+
done();
1007+
});
1008+
});
1009+
1010+
describe('findConditions', () => {
1011+
test('matching', () => {
1012+
const stack = new Stack();
1013+
new CfnCondition(stack, 'Foo', {
1014+
expression: Fn.conditionEquals('Bar', 'Baz'),
1015+
});
1016+
1017+
new CfnCondition(stack, 'Qux', {
1018+
expression: Fn.conditionNot(Fn.conditionEquals('Quux', 'Quuz')),
1019+
});
1020+
1021+
const inspect = Template.fromStack(stack);
1022+
const firstCondition = inspect.findConditions('Foo');
1023+
expect(firstCondition).toEqual({
1024+
Foo: {
1025+
'Fn::Equals': [
1026+
'Bar',
1027+
'Baz',
1028+
],
1029+
},
1030+
});
1031+
1032+
const secondCondition = inspect.findConditions('Qux');
1033+
expect(secondCondition).toEqual({
1034+
Qux: {
1035+
'Fn::Not': [
1036+
{
1037+
'Fn::Equals': [
1038+
'Quux',
1039+
'Quuz',
1040+
],
1041+
},
1042+
],
1043+
},
1044+
});
1045+
});
1046+
1047+
test('not matching', () => {
1048+
const stack = new Stack();
1049+
new CfnCondition(stack, 'Foo', {
1050+
expression: Fn.conditionEquals('Bar', 'Baz'),
1051+
});
1052+
1053+
const inspect = Template.fromStack(stack);
1054+
const result = inspect.findMappings('Bar');
1055+
expect(Object.keys(result).length).toEqual(0);
1056+
});
1057+
1058+
test('matching with specific outputName', () => {
1059+
const stack = new Stack();
1060+
new CfnCondition(stack, 'Foo', {
1061+
expression: Fn.conditionEquals('Bar', 'Baz'),
1062+
});
1063+
1064+
const inspect = Template.fromStack(stack);
1065+
const result = inspect.findConditions('Foo', { 'Fn::Equals': ['Bar', 'Baz'] });
1066+
expect(result).toEqual({
1067+
Foo: {
1068+
'Fn::Equals': [
1069+
'Bar',
1070+
'Baz',
1071+
],
1072+
},
1073+
});
1074+
});
1075+
1076+
test('not matching specific output name', () => {
1077+
const stack = new Stack();
1078+
new CfnCondition(stack, 'Foo', {
1079+
expression: Fn.conditionEquals('Bar', 'Baz'),
1080+
});
1081+
1082+
const inspect = Template.fromStack(stack);
1083+
const result = inspect.findConditions('Foo', { 'Fn::Equals': ['Bar', 'Qux'] });
1084+
expect(Object.keys(result).length).toEqual(0);
1085+
});
1086+
});
9431087
});
9441088

9451089
function expectToThrow(fn: () => void, msgs: (RegExp | string)[], done: jest.DoneCallback): void {

Diff for: packages/@aws-cdk/aws-apigateway/lib/authorizers/lambda.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as iam from '@aws-cdk/aws-iam';
22
import * as lambda from '@aws-cdk/aws-lambda';
3-
import { Duration, Lazy, Names, Stack } from '@aws-cdk/core';
3+
import { Arn, ArnFormat, Duration, Lazy, Names, Stack } from '@aws-cdk/core';
44
import { Construct } from 'constructs';
55
import { CfnAuthorizer } from '../apigateway.generated';
66
import { Authorizer, IAuthorizer } from '../authorizer';
@@ -254,5 +254,6 @@ export class RequestAuthorizer extends LambdaAuthorizer {
254254
* constructs the authorizerURIArn.
255255
*/
256256
function lambdaAuthorizerArn(handler: lambda.IFunction) {
257-
return `arn:${Stack.of(handler).partition}:apigateway:${Stack.of(handler).region}:lambda:path/2015-03-31/functions/${handler.functionArn}/invocations`;
257+
const { region, partition } = Arn.split( handler.functionArn, ArnFormat.COLON_RESOURCE_NAME);
258+
return `arn:${partition}:apigateway:${region}:lambda:path/2015-03-31/functions/${handler.functionArn}/invocations`;
258259
}

Diff for: packages/@aws-cdk/aws-apigateway/test/authorizers/integ.request-authorizer.lit.expected.json

+28-2
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,37 @@
253253
[
254254
"arn:",
255255
{
256-
"Ref": "AWS::Partition"
256+
"Fn::Select": [
257+
1,
258+
{
259+
"Fn::Split": [
260+
":",
261+
{
262+
"Fn::GetAtt": [
263+
"MyAuthorizerFunction70F1223E",
264+
"Arn"
265+
]
266+
}
267+
]
268+
}
269+
]
257270
},
258271
":apigateway:",
259272
{
260-
"Ref": "AWS::Region"
273+
"Fn::Select": [
274+
3,
275+
{
276+
"Fn::Split": [
277+
":",
278+
{
279+
"Fn::GetAtt": [
280+
"MyAuthorizerFunction70F1223E",
281+
"Arn"
282+
]
283+
}
284+
]
285+
}
286+
]
261287
},
262288
":lambda:path/2015-03-31/functions/",
263289
{

0 commit comments

Comments
 (0)