Skip to content

Commit 1862607

Browse files
committed
Allow provider tags on AWS::ApiGateway::RestApi
1 parent 7bad692 commit 1862607

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

lib/plugins/aws/package/compile/events/api-gateway/lib/rest-api.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,31 @@ module.exports = {
4747
const DisableExecuteApiEndpoint =
4848
apiGateway.disableDefaultEndpoint == null ? undefined : apiGateway.disableDefaultEndpoint;
4949

50+
const properties = {
51+
Name: this.provider.naming.getApiGatewayName(),
52+
BinaryMediaTypes,
53+
DisableExecuteApiEndpoint,
54+
EndpointConfiguration,
55+
};
56+
57+
// Tags
58+
if (
59+
this.serverless.service.provider.tags &&
60+
this.serverless.service.provider.restApi &&
61+
this.serverless.service.provider.restApi.useProviderTags
62+
) {
63+
properties.Tags = Object.entries(this.serverless.service.provider.tags).map(
64+
([Key, Value]) => ({
65+
Key,
66+
Value,
67+
})
68+
);
69+
}
70+
5071
_.merge(this.serverless.service.provider.compiledCloudFormationTemplate.Resources, {
5172
[this.apiGatewayRestApiLogicalId]: {
5273
Type: 'AWS::ApiGateway::RestApi',
53-
Properties: {
54-
Name: this.provider.naming.getApiGatewayName(),
55-
BinaryMediaTypes,
56-
DisableExecuteApiEndpoint,
57-
EndpointConfiguration,
58-
},
74+
Properties: properties,
5975
},
6076
});
6177

lib/plugins/aws/provider.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,13 @@ class AwsProvider {
12891289
'sa-east-1',
12901290
],
12911291
},
1292+
restApi: {
1293+
type: 'object',
1294+
properties: {
1295+
useProviderTags: { type: 'boolean' },
1296+
},
1297+
additionalProperties: false,
1298+
},
12921299
role: { $ref: '#/definitions/awsLambdaRole' },
12931300
rolePermissionsBoundary: { $ref: '#/definitions/awsArnString' },
12941301
rollbackConfiguration: {

types/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,9 @@ export interface AWS {
10581058
| "me-central-1"
10591059
| "me-south-1"
10601060
| "sa-east-1";
1061+
restApi?: {
1062+
useProviderTags?: boolean;
1063+
};
10611064
role?: AwsLambdaRole;
10621065
rolePermissionsBoundary?: AwsArnString;
10631066
rollbackConfiguration?: {

0 commit comments

Comments
 (0)