-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Labels
@aws-cdk/aws-apigatewayRelated to Amazon API GatewayRelated to Amazon API GatewayguidanceQuestion that needs advice or information.Question that needs advice or information.
Description
Template format error is thrown though nested stacks are used.
Using single stack was throwing template format error with resource exceeds 200, hence started with nested stack, but issue still the same.
Reproduction Steps
- Use case have 3 lambda functions, with 70 api with different method and resource in a single RestAPI.
- it has been split into 3 nested stack for each with lambda and its associated API.
class StackOne(aws_cloudformation.NestedStack):
def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
funcOne = aws_lambda.Function(self, func_suffix, handler='handler',
function_name='name', role=aws_iam.Role.from_role_arn(self,'role', role),
runtime=aws_lambda.Runtime.JAVA_8, code=aws_lambda.S3Code(bucket, 'path'))
request_template = {"name": "value"}
integration_responses = [{'statusCode': '200',
'responseParameters': {'method.response.header.Access-Control-Allow-Origin': "'*'"}}]
method_responses = [{'statusCode': '200',
'responseParameters': {'method.response.header.Access-Control-Allow-Origin': True}}]
stage_options = aws_apigateway.StageOptions(stage_name='name',variables=dict(key='value'))
self.rest_api = aws_apigateway.RestApi(self, "gateway", rest_api_name="gateway", deploy_options=stage_options)
api_entity = rest_api.root.add_resource('api')
api_integ = aws_apigateway.LambdaIntegration(funcOne, proxy=False, request_templates={'application/json':json.dumps(cap_activate_factor_tempate)},
integration_responses=integration_responses, allow_test_invoke=False,
passthrough_behavior=aws_apigateway.PassthroughBehavior.WHEN_NO_TEMPLATES)
api_entity.add_method('POST', api_integ, method_responses=method_responses)
class StackTwo(aws_cloudformation.NestedStack):
def __init__(self, scope: core.Construct, id: str, rest_api:aws_apigateway.RestApi, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
funcTwo = aws_lambda.Function(self, func_suffix, handler='handler',
function_name='name', role=aws_iam.Role.from_role_arn(self,'role', role),
runtime=aws_lambda.Runtime.JAVA_8, code=aws_lambda.S3Code(bucket, 'path'))
request_template = {"name": "value"}
integration_responses = [{'statusCode': '200',
'responseParameters': {'method.response.header.Access-Control-Allow-Origin': "'*'"}}]
method_responses = [{'statusCode': '200',
'responseParameters': {'method.response.header.Access-Control-Allow-Origin': True}}]
api_entity = rest_api.root.get_resource('api')
v1_entity = api_entity.add_resource('v1')
v1_integ = aws_apigateway.LambdaIntegration(funcTwo, proxy=False, request_templates={'application/json':json.dumps(cap_activate_factor_tempate)},
integration_responses=integration_responses, allow_test_invoke=False,
passthrough_behavior=aws_apigateway.PassthroughBehavior.WHEN_NO_TEMPLATES)
v1_entity.add_method('POST', v1_integ, method_responses=method_responses)
class MainStack(core.Stack):
def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
stack_one = StackOne(self, 'StackOne')
StackTwo(self, 'StackTwo', rest_api=stack_one.rest_api)
app = core.App()
MainStack(app, 'MainStack', env={'region':'us-east-1'})Error Log
Template format error: Number of resources, 204, is greater than maximum allowed, 200
Environment
- CLI Version : 1.31.0
- Framework Version:
- OS : Windows
- Language : Python3.7
Other
This is 🐛 Bug Report
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-apigatewayRelated to Amazon API GatewayRelated to Amazon API GatewayguidanceQuestion that needs advice or information.Question that needs advice or information.