Skip to content

Commit

Permalink
feat(aws-openapi-lambda): make names unique (#987)
Browse files Browse the repository at this point in the history
* Adjust names of functions and RestAPIs

* Cleanup some debugging scraps

* Minor fix requires new snapshots

* Remove leftover file
  • Loading branch information
biffgaut committed Aug 23, 2023
1 parent 555ff39 commit be9997a
Show file tree
Hide file tree
Showing 7 changed files with 240 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class OpenApiGatewayToLambda extends Construct {
lambdaFunction: defaults.buildLambdaFunction(this, {
existingLambdaObj: apiIntegration.existingLambdaObj,
lambdaFunctionProps: apiIntegration.lambdaFunctionProps
}, `ApiFunction${lambdaCounter++}`)
}, `${apiIntegration.id}ApiFunction${lambdaCounter++}`)
};
} else {
throw new Error(`One of existingLambdaObj or lambdaFunctionProps must be specified for the api integration with id: ${apiIntegration.id}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,10 +806,30 @@
]
}
},
"Name": "SpecRestApi"
"Name": {
"Fn::Join": [
"",
[
"OpenApiGatewayToLambda-",
{
"Fn::Select": [
2,
{
"Fn::Split": [
"/",
{
"Ref": "AWS::StackId"
}
]
}
]
}
]
]
}
}
},
"OpenApiGatewayToLambdaSpecRestApiDeploymentC8BD0775a5995a76cd028623a8c53fad4d5dfe6e": {
"OpenApiGatewayToLambdaSpecRestApiDeploymentC8BD0775114a8d1d0c9bf9b9d904a22f099d1d64": {
"Type": "AWS::ApiGateway::Deployment",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -844,7 +864,7 @@
"Format": "{\"requestId\":\"$context.requestId\",\"ip\":\"$context.identity.sourceIp\",\"user\":\"$context.identity.user\",\"caller\":\"$context.identity.caller\",\"requestTime\":\"$context.requestTime\",\"httpMethod\":\"$context.httpMethod\",\"resourcePath\":\"$context.resourcePath\",\"status\":\"$context.status\",\"protocol\":\"$context.protocol\",\"responseLength\":\"$context.responseLength\"}"
},
"DeploymentId": {
"Ref": "OpenApiGatewayToLambdaSpecRestApiDeploymentC8BD0775a5995a76cd028623a8c53fad4d5dfe6e"
"Ref": "OpenApiGatewayToLambdaSpecRestApiDeploymentC8BD0775114a8d1d0c9bf9b9d904a22f099d1d64"
},
"MethodSettings": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Description": "Integration Test for aws-openapigateway-lambda",
"Resources": {
"OpenApiGatewayToLambdaApiFunction0ServiceRole5E78431B": {
"OpenApiGatewayToLambdaMessagesHandlerApiFunction0ServiceRoleB5DC63A9": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
Expand Down Expand Up @@ -56,7 +56,7 @@
]
}
},
"OpenApiGatewayToLambdaApiFunction0ServiceRoleDefaultPolicyE0627027": {
"OpenApiGatewayToLambdaMessagesHandlerApiFunction0ServiceRoleDefaultPolicy4563083B": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
Expand All @@ -72,10 +72,10 @@
],
"Version": "2012-10-17"
},
"PolicyName": "OpenApiGatewayToLambdaApiFunction0ServiceRoleDefaultPolicyE0627027",
"PolicyName": "OpenApiGatewayToLambdaMessagesHandlerApiFunction0ServiceRoleDefaultPolicy4563083B",
"Roles": [
{
"Ref": "OpenApiGatewayToLambdaApiFunction0ServiceRole5E78431B"
"Ref": "OpenApiGatewayToLambdaMessagesHandlerApiFunction0ServiceRoleB5DC63A9"
}
]
},
Expand All @@ -90,7 +90,7 @@
}
}
},
"OpenApiGatewayToLambdaApiFunction0260B7595": {
"OpenApiGatewayToLambdaMessagesHandlerApiFunction0E78C5307": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
Expand All @@ -101,7 +101,7 @@
},
"Role": {
"Fn::GetAtt": [
"OpenApiGatewayToLambdaApiFunction0ServiceRole5E78431B",
"OpenApiGatewayToLambdaMessagesHandlerApiFunction0ServiceRoleB5DC63A9",
"Arn"
]
},
Expand All @@ -112,8 +112,8 @@
}
},
"DependsOn": [
"OpenApiGatewayToLambdaApiFunction0ServiceRoleDefaultPolicyE0627027",
"OpenApiGatewayToLambdaApiFunction0ServiceRole5E78431B"
"OpenApiGatewayToLambdaMessagesHandlerApiFunction0ServiceRoleDefaultPolicy4563083B",
"OpenApiGatewayToLambdaMessagesHandlerApiFunction0ServiceRoleB5DC63A9"
],
"Metadata": {
"cfn_nag": {
Expand All @@ -134,13 +134,13 @@
}
}
},
"OpenApiGatewayToLambdaApiFunction0PermitAPIGInvocation16ED06C4": {
"OpenApiGatewayToLambdaMessagesHandlerApiFunction0PermitAPIGInvocationB70BC520": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"OpenApiGatewayToLambdaApiFunction0260B7595",
"OpenApiGatewayToLambdaMessagesHandlerApiFunction0E78C5307",
"Arn"
]
},
Expand Down Expand Up @@ -171,7 +171,7 @@
}
}
},
"OpenApiGatewayToLambdaApiFunction1ServiceRole71570A60": {
"OpenApiGatewayToLambdaPhotosHandlerApiFunction1ServiceRoleA572C749": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
Expand Down Expand Up @@ -226,7 +226,7 @@
]
}
},
"OpenApiGatewayToLambdaApiFunction1ServiceRoleDefaultPolicy23E5856D": {
"OpenApiGatewayToLambdaPhotosHandlerApiFunction1ServiceRoleDefaultPolicy389AA3BA": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyDocument": {
Expand All @@ -242,10 +242,10 @@
],
"Version": "2012-10-17"
},
"PolicyName": "OpenApiGatewayToLambdaApiFunction1ServiceRoleDefaultPolicy23E5856D",
"PolicyName": "OpenApiGatewayToLambdaPhotosHandlerApiFunction1ServiceRoleDefaultPolicy389AA3BA",
"Roles": [
{
"Ref": "OpenApiGatewayToLambdaApiFunction1ServiceRole71570A60"
"Ref": "OpenApiGatewayToLambdaPhotosHandlerApiFunction1ServiceRoleA572C749"
}
]
},
Expand All @@ -260,7 +260,7 @@
}
}
},
"OpenApiGatewayToLambdaApiFunction1C23FE1AE": {
"OpenApiGatewayToLambdaPhotosHandlerApiFunction1C42C52E8": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
Expand All @@ -271,7 +271,7 @@
},
"Role": {
"Fn::GetAtt": [
"OpenApiGatewayToLambdaApiFunction1ServiceRole71570A60",
"OpenApiGatewayToLambdaPhotosHandlerApiFunction1ServiceRoleA572C749",
"Arn"
]
},
Expand All @@ -282,8 +282,8 @@
}
},
"DependsOn": [
"OpenApiGatewayToLambdaApiFunction1ServiceRoleDefaultPolicy23E5856D",
"OpenApiGatewayToLambdaApiFunction1ServiceRole71570A60"
"OpenApiGatewayToLambdaPhotosHandlerApiFunction1ServiceRoleDefaultPolicy389AA3BA",
"OpenApiGatewayToLambdaPhotosHandlerApiFunction1ServiceRoleA572C749"
],
"Metadata": {
"cfn_nag": {
Expand All @@ -304,13 +304,13 @@
}
}
},
"OpenApiGatewayToLambdaApiFunction1PermitAPIGInvocation61F651CA": {
"OpenApiGatewayToLambdaPhotosHandlerApiFunction1PermitAPIGInvocationA20E40FB": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"OpenApiGatewayToLambdaApiFunction1C23FE1AE",
"OpenApiGatewayToLambdaPhotosHandlerApiFunction1C42C52E8",
"Arn"
]
},
Expand Down Expand Up @@ -738,7 +738,7 @@
":lambda:path/2015-03-31/functions/",
{
"Fn::GetAtt": [
"OpenApiGatewayToLambdaApiFunction0260B7595",
"OpenApiGatewayToLambdaMessagesHandlerApiFunction0E78C5307",
"Arn"
]
},
Expand All @@ -753,7 +753,7 @@
":lambda:path/2015-03-31/functions/",
{
"Fn::GetAtt": [
"OpenApiGatewayToLambdaApiFunction1C23FE1AE",
"OpenApiGatewayToLambdaPhotosHandlerApiFunction1C42C52E8",
"Arn"
]
},
Expand Down Expand Up @@ -805,10 +805,30 @@
]
}
},
"Name": "SpecRestApi"
"Name": {
"Fn::Join": [
"",
[
"OpenApiGatewayToLambda-",
{
"Fn::Select": [
2,
{
"Fn::Split": [
"/",
{
"Ref": "AWS::StackId"
}
]
}
]
}
]
]
}
}
},
"OpenApiGatewayToLambdaSpecRestApiDeploymentC8BD077553ca81e8e1b2799986bf3d0ef9cf2ff0": {
"OpenApiGatewayToLambdaSpecRestApiDeploymentC8BD0775c586d865ce613dde0b09710274a96485": {
"Type": "AWS::ApiGateway::Deployment",
"Properties": {
"RestApiId": {
Expand Down Expand Up @@ -843,7 +863,7 @@
"Format": "{\"requestId\":\"$context.requestId\",\"ip\":\"$context.identity.sourceIp\",\"user\":\"$context.identity.user\",\"caller\":\"$context.identity.caller\",\"requestTime\":\"$context.requestTime\",\"httpMethod\":\"$context.httpMethod\",\"resourcePath\":\"$context.resourcePath\",\"status\":\"$context.status\",\"protocol\":\"$context.protocol\",\"responseLength\":\"$context.responseLength\"}"
},
"DeploymentId": {
"Ref": "OpenApiGatewayToLambdaSpecRestApiDeploymentC8BD077553ca81e8e1b2799986bf3d0ef9cf2ff0"
"Ref": "OpenApiGatewayToLambdaSpecRestApiDeploymentC8BD0775c586d865ce613dde0b09710274a96485"
},
"MethodSettings": [
{
Expand Down
Loading

0 comments on commit be9997a

Please sign in to comment.