Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aws_cdk.aws_dynamodb): adding replication_regions to Table construct causes build/deploy errors #17962

Closed
vitaliknet opened this issue Dec 11, 2021 · 3 comments
Assignees
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@vitaliknet
Copy link

vitaliknet commented Dec 11, 2021

General Issue

"sam-beta-cdk build" fails with replication_regions defined in aws_dynamodb.Table

The Question

sam-beta-cdk build fails with replication_regions parameter, but builds successfully when replication_regions line is commented out.

from aws_cdk import App, Stack
from aws_cdk import aws_dynamodb as dynamodb

from constructs import Construct

class MyStack(Stack):
    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        global_table = dynamodb.Table(self, "Table",
            partition_key=dynamodb.Attribute(name="id", type=dynamodb.AttributeType.STRING),
            replication_regions=["us-east-1", "us-west-2"]
        )

app = App()
MyStack(app, "dynamodb-test")

app.synth()

sam-beta-cdk build

Synthesizing CDK App
Traceback (most recent call last):
  File "runpy.py", line 194, in _run_module_as_main
  File "runpy.py", line 87, in _run_code
  File "C:\Program Files\Amazon\AWSSAMCLI_BETA_CDK\runtime\lib\site-packages\samcli\__main__.py", line 12, in <module>
    cli(prog_name="sam")
  File "C:\Program Files\Amazon\AWSSAMCLI_BETA_CDK\runtime\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI_BETA_CDK\runtime\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Program Files\Amazon\AWSSAMCLI_BETA_CDK\runtime\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Program Files\Amazon\AWSSAMCLI_BETA_CDK\runtime\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Program Files\Amazon\AWSSAMCLI_BETA_CDK\runtime\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI_BETA_CDK\runtime\lib\site-packages\samcli\lib\iac\utils\helpers.py", line 50, in wrapper
    iac_plugin, project = get_iac_plugin(project_type, kwargs, with_build)
  File "C:\Program Files\Amazon\AWSSAMCLI_BETA_CDK\runtime\lib\site-packages\samcli\lib\iac\utils\helpers.py", line 40, in get_iac_plugin
    project = iac_plugin.get_project(lookup_paths)
  File "C:\Program Files\Amazon\AWSSAMCLI_BETA_CDK\runtime\lib\site-packages\samcli\lib\iac\cdk\plugin.py", line 114, in get_project
    project = self._get_project_from_cloud_assembly(cloud_assembly_dir)
  File "C:\Program Files\Amazon\AWSSAMCLI_BETA_CDK\runtime\lib\site-packages\samcli\lib\iac\cdk\plugin.py", line 211, in _get_project_from_cloud_assembly
    stacks: List[Stack] = [self._build_stack(cloud_assembly, ca_stack) for ca_stack in cloud_assembly.stacks]
  File "C:\Program Files\Amazon\AWSSAMCLI_BETA_CDK\runtime\lib\site-packages\samcli\lib\iac\cdk\plugin.py", line 211, in <listcomp>
    stacks: List[Stack] = [self._build_stack(cloud_assembly, ca_stack) for ca_stack in cloud_assembly.stacks]
  File "C:\Program Files\Amazon\AWSSAMCLI_BETA_CDK\runtime\lib\site-packages\samcli\lib\iac\cdk\plugin.py", line 232, in _build_stack
    self._build_resources_section(assets, ca_stack, cloud_assembly, section, section_dict)
  File "C:\Program Files\Amazon\AWSSAMCLI_BETA_CDK\runtime\lib\site-packages\samcli\lib\iac\cdk\plugin.py", line 292, in _build_resources_section
    asset = assets[asset_path]
KeyError: 'dynamodbtestawscdkawsdynamodbReplicaProviderEE4E8EAD.nested.template.json'

CDK CLI Version

2.1.0 (build f4f18b1)

Framework Version

No response

Node.js Version

14.5.0, same results with 16.3.0

OS

Windows 10

Language

Python

Language Version

3.8.5

Other information

I came across this error in an attempt to troubleshoot cdk deploy failure of a more complex CDK app with multiple stages/stacks. When replication_regions is defined in aws_dynamodb.Table, the nested replication stack fails to create IsCompleteHandler7073F4DA and OnEventHandler42BEBAE0 resources:

Resource handler returned message: "Uploaded file must be a non-empty zip (Service: Lambda, Status Code: 400, Request ID: c2cd5506-2d68-4862-967f-2a61a8ab9b5e, Extended Request ID: null)" (RequestToken: 9e70ee27-c2b2-a433-6301-1db455fc1438, HandlerErrorCode: InvalidRequest)

Resource handler returned message: "Uploaded file must be a non-empty zip (Service: Lambda, Status Code: 400, Request ID: 87ddb923-6358-4643-b5a8-a1dca704bb44, Extended Request ID: null)" (RequestToken: 86c51774-2eca-3f8c-85bc-ce8d9c7ab84b, HandlerErrorCode: InvalidRequest)
@vitaliknet vitaliknet added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Dec 11, 2021
@github-actions github-actions bot added the @aws-cdk/aws-dynamodb Related to Amazon DynamoDB label Dec 11, 2021
@skinny85
Copy link
Contributor

Hey @vitaliknet,

thanks for opening the issue. To help me pin-down the problem, can you tell me whether you get the same problem when using pure CDK, without sam-beta-cdk? So, when running cdk synth / cdk deploy?

Thanks,
Adam

@skinny85 skinny85 added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Dec 13, 2021
@vitaliknet
Copy link
Author

Hi @skinny85 -

the issue was indeed coming from sam-beta-cdk, as discussed in aws/aws-sam-cli#2849

The original "Uploaded file must be a non-empty zip" issue was related to node version, addressed in serverless/serverless#8772 (comment).

Thanks!

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants