awslabs / route53-dynamic-dns-with-lambda

A Dynamic DNS system built with API Gateway, Lambda & Route 53.
Apache License 2.0
486 stars 167 forks source link

CDK Deploy Fails to create dyndnsfn..... #46

Closed JD-Atkinson closed 11 months ago

JD-Atkinson commented 1 year ago

I'm trying to implement this solution on a new Linux2023 AWS system. I was able to successfully complete the "cdk bootstrap" after figuring out all the permissions needed. Now on "cdk deploy" after step 3/8 the stack installation fails and reverts. I've tried changing the nvm version, adding permissions, checking roles..... what could be the problem and how to identify it?

DyndnsStack: creating CloudFormation changeset... 3:49:57 PM | CREATE_FAILED | AWS::Lambda::Function | dyndnsfnA1D8B956 Properties validation failed for resource dyndnsfnA1D8B956 with message:

/FunctionName: expected minLength: 1, actual: 0

❌ DyndnsStack failed: Error: The stack named DyndnsStack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Properties validation failed for resource dyndnsfnA1D8B956 with message:

/FunctionName: expected minLength: 1, actual: 0

at FullCloudFormationDeployment.monitorDeployment (/home/ec2-user/.nvm/versions/node/v18.17.1/lib/node_modules/aws-cdk/lib/index.js:443:10236)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.deployStack2 [as deployStack] (/home/ec2-user/.nvm/versions/node/v18.17.1/lib/node_modules/aws-cdk/lib/index.js:446:153718)
at async /home/ec2-user/.nvm/versions/node/v18.17.1/lib/node_modules/aws-cdk/lib/index.js:446:137166

❌ Deployment failed: Error: The stack named DyndnsStack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Properties validation failed for resource dyndnsfnA1D8B956 with message:

/FunctionName: expected minLength: 1, actual: 0

at FullCloudFormationDeployment.monitorDeployment (/home/ec2-user/.nvm/versions/node/v18.17.1/lib/node_modules/aws-cdk/lib/index.js:443:10236)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.deployStack2 [as deployStack] (/home/ec2-user/.nvm/versions/node/v18.17.1/lib/node_modules/aws-cdk/lib/index.js:446:153718)
at async /home/ec2-user/.nvm/versions/node/v18.17.1/lib/node_modules/aws-cdk/lib/index.js:446:137166

The stack named DyndnsStack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Properties validation failed for resource dyndnsfnA1D8B956 with message:

/FunctionName: expected minLength: 1, actual: 0

JD-Atkinson commented 1 year ago

Here is the -vv output: DyndnsStack | 4/8 | 8:04:40 PM | CREATE_IN_PROGRESS | AWS::Lambda::Function | dyndns_fn (dyndnsfnA1D8B956) DyndnsStack | 4/8 | 8:04:40 PM | CREATE_FAILED | AWS::Lambda::Function | dyndns_fn (dyndnsfnA1D8B956) Properties validation failed for resource dyndnsfnA1D8B956 with message:

/FunctionName: expected minLength: 1, actual: 0

DyndnsStack | 4/8 | 8:04:41 PM | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack | DyndnsStack The following resource(s) failed to create: [dyndnsfnA1D8B956]. Rollback requested by user.

JD-Atkinson commented 1 year ago

Some other notes...

  1. "cdk deploy" fails to launch if the runtime is not edited as below to make it python 3.11

if runtime_function_name.value_asstring !="": fn = lambda.Function(self, "dyndnsfn", runtime=lambda.Runtime.PYTHON_311, architecture=lambda.Architecture.ARM_64, handler="index.lambdahandler", code=lambda.Code.from_asset("lambda"), role=fn_role, function_name=runtime_function_name.value_as_string,

Provide DynammoDB table name as enviroment variable

            environment={
             "ddns_config_table":table.table_name
            }
        )
    else:

because it complains that the runtime isn't the latest supported version if this edit is not made in dyndns/dyndns_stack.py

"[Error at /DyndnsStack/dyndns_fn/Resource] AwsSolutions-L1: The non-container Lambda function is not configured to use the latest runtime version. Use the latest available runtime for the targeted language to avoid technical debt. Runtimes specific to a language or framework version are deprecated when the version reaches end of life. This rule only applies to non-container Lambda functions"

  1. After that change is made, it runs but can't create the lambda function. I suspect it is because there are differences in the Python 3.11 that is required that aren't in the actual script. But I don't know how to fix it.
masberta commented 11 months ago

Hello, currently reviewing this. Will it be possible for you to try using 3_9 on a Cloud9 workspace to see if you're able to deploy without specifying 3_11?

Also can you please let me know CDK version you're running on Linux2023 AWS?

MiguelMLorente commented 11 months ago

Hello! Hope this can help. I was trying to set this up and encountered this same issue. I was able to resolve it by running cdk deploy --parameters ddFunction="lambda_ddns". If this is required, it would be nice to have it in the readme. Also, I encountered a problem with the runtime, since it looks like they are moving towards Python 3.11. I changed it in the code manually. If this is not a problem within the lambda handler, I recommend to upgrade the runtime in the repo also.

masberta commented 11 months ago

Thanks all for looking into this, I've merged a fix as per description below. Tested this in Cloud9 environment and local development machine and was able to deploy on 3.11 runtime. Please open a new issue referring to this one if you still encounter issues.

Pull request changes: Updated requirements.txt by removing version and added cdk-nag Added instructions on README.md to run pip install -r requirements.txt to ensure CDK is up to date. Modified CDK stack by removing option to name the Lambda function and updated to 3.11 runtime