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

ValidationError: Parameter values specified when using DynamoDB Global module #2900

Closed
bigluck opened this issue Jun 18, 2019 · 4 comments · Fixed by #4540
Closed

ValidationError: Parameter values specified when using DynamoDB Global module #2900

bigluck opened this issue Jun 18, 2019 · 4 comments · Fixed by #4540
Assignees
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. needs-reproduction This issue needs reproduction.

Comments

@bigluck
Copy link

bigluck commented Jun 18, 2019

Describe the bug
Hi everybody,
I'm building an modular infrastructure but I'm fighting with this error:

failed: ValidationError: Parameter values specified for a template which does not require them.
Parameter values specified for a template which does not require them.

The stack is very simple:

First stack:
A VPC only stack deployed with the microservices-vpc-cdk-dev-us-west-2 stack name.
Second stack:
A ECS Cluster + a Global DynamoDB Table, the ECS Cluster use exported parameters from the first stack.

The problem occurs on the second stack only if the Global DynamoDB Table is added; otherwise CDK works as expected.

To Reproduce

The ECS Cluster is very simple:

export class MyResources extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props: cdk.StackProps) {
    super(scope, id, props);

    // VPC
    const vpcId = cdk.Fn.importValue(`MyStack1Prefix-VpcId-cdk-dev`);
    const availabilityZones = cdk.Fn.split(',', cdk.Fn.importValue(`MyStack1Prefix-AvailabilityZones-cdk-dev`));
    const vpc = ec2.Vpc.fromVpcAttributes(this, id, {
      vpcId,
      availabilityZones,
    });

    // ECS Cluster
    const clusterName = `service1-cdk-dev`;
    const cluster = new ecs.Cluster(this, id, {
      vpc,
      clusterName,
    });
  }

This configuration works as expected and the entire Stack are deployed, CDK create e deploy only a CF stack: service1-ecs-cdk-dev-us-west-2.

By adding the DynamoDB Global Table definition under the ECS cluster I'm getting the error above:

    // DynamoDB Table
    const tableName = `table1-cdk-dev`;
    const table = new dynamodbGlobal.GlobalTable(this, id, {
      tableName: tableName,
      regions: ['us-west-2', 'eu-west-1'],
      partitionKey: {
        name: 'primary_key',
        type: dynamodb.AttributeType.String,
      },
      billingMode: dynamodb.BillingMode.PayPerRequest,
    });

Now CDK has created & deployed also:

  • service1ecscdkdevuswest2Service1TableCustomResourceBD055B07
  • service1ecscdkdevuswest2Service1TableService1Tableuswest2EBB183CF

Here a detailed log of the cfn.createChangeSet method invoked:

service1ecscdkdevuswest2Service1TableService1Tableuswest2EBB183CF: creating CloudFormation changeset...
{
  "Capabilities": [
    "CAPABILITY_IAM",
    "CAPABILITY_NAMED_IAM",
    "CAPABILITY_AUTO_EXPAND"
  ],
  "ChangeSetName": "CDK-44238698-0368-48eb-ac5e-c5cceddf5b2f",
  "ChangeSetType": "CREATE",
  "Description": "CDK Changeset for execution 44238698-0368-48eb-ac5e-c5cceddf5b2f",
  "Parameters": [],
  "StackName": "service1ecscdkdevuswest2Service1TableService1Tableuswest2EBB183CF",
  "Tags": [],
  "TemplateURL": "https://cdktoolkit-stagingbucket-XXXXXXXXXXXX.s3.amazonaws.com/cdk/service1ecscdkdevuswest2Service1TableService1Tableuswest2EBB183CF/fe9b0deb6031ed5787a739072d61364f6c60e4361342f66c8c62b5b82546a177.yml"
}

service1ecscdkdevuswest2Service1TableCustomResourceBD055B07: creating CloudFormation changeset...
{
  "Capabilities": [
    "CAPABILITY_IAM",
    "CAPABILITY_NAMED_IAM",
    "CAPABILITY_AUTO_EXPAND"
  ],
  "ChangeSetName": "CDK-ba0fea7c-ccd9-4228-aa66-61eec02444a1",
  "ChangeSetType": "CREATE",
  "Description": "CDK Changeset for execution ba0fea7c-ccd9-4228-aa66-61eec02444a1",
  "Parameters": [
    {
      "ParameterKey": "SingletonLambdaD38B65A66B544FB69BAD9CD40A6DAC12CodeS3BucketF66FB543",
      "ParameterValue": "cdktoolkit-stagingbucket-XXXXXXXXXXXX"
    },
    {
      "ParameterKey": "SingletonLambdaD38B65A66B544FB69BAD9CD40A6DAC12CodeS3VersionKey59DB89A0",
      "ParameterValue": "assets/service1ecscdkdevuswest2Service1TableCustomResourceSingletonLambdaD38B65A66B544FB69BAD9CD40A6DAC12Code49F4FB40/||d24b53740e41ce155a5c316af128401539cb153c06281b70375c7a4015f7314d.zip"
    },
    {
      "ParameterKey": "SingletonLambdaD38B65A66B544FB69BAD9CD40A6DAC12CodeArtifactHashCE92982B",
      "ParameterValue": "d24b53740e41ce155a5c316af128401539cb153c06281b70375c7a4015f7314d"
    }
  ],
  "StackName": "service1ecscdkdevuswest2Service1TableCustomResourceBD055B07",
  "Tags": [],
  "TemplateURL": "https://cdktoolkit-stagingbucket-XXXXXXXXXXXX.s3.amazonaws.com/cdk/service1ecscdkdevuswest2Service1TableCustomResourceBD055B07/53d1d7f20682c3bdac8df595d528ecf2d1f4b192691068ceba99ff6e1bf3fc0b.yml"
}

service1-ecs-cdk-dev-us-west-2: creating CloudFormation changeset...
{
  "Capabilities": [
    "CAPABILITY_IAM",
    "CAPABILITY_NAMED_IAM",
    "CAPABILITY_AUTO_EXPAND"
  ],
  "ChangeSetName": "CDK-1d52709f-35d0-4f74-a522-5cd28f5490cc",
  "ChangeSetType": "CREATE",
  "Description": "CDK Changeset for execution 1d52709f-35d0-4f74-a522-5cd28f5490cc",
  "Parameters": [
    {
      "ParameterKey": "SingletonLambdaD38B65A66B544FB69BAD9CD40A6DAC12CodeS3BucketF66FB543",
      "ParameterValue": "cdktoolkit-stagingbucket-XXXXXXXXXXXX"
    },
    {
      "ParameterKey": "SingletonLambdaD38B65A66B544FB69BAD9CD40A6DAC12CodeS3VersionKey59DB89A0",
      "ParameterValue": "assets/service1ecscdkdevuswest2Service1TableCustomResourceSingletonLambdaD38B65A66B544FB69BAD9CD40A6DAC12Code49F4FB40/||d24b53740e41ce155a5c316af128401539cb153c06281b70375c7a4015f7314d.zip"
    },
    {
      "ParameterKey": "SingletonLambdaD38B65A66B544FB69BAD9CD40A6DAC12CodeArtifactHashCE92982B",
      "ParameterValue": "d24b53740e41ce155a5c316af128401539cb153c06281b70375c7a4015f7314d"
    }
  ],
  "StackName": "service1-ecs-cdk-dev-us-west-2",
  "Tags": [],
  "TemplateURL": "https://cdktoolkit-stagingbucket-XXXXXXXXXXXX.s3.amazonaws.com/cdk/service1-ecs-cdk-dev-us-west-2/48d3ff2b70c9b64d2d2494420804765881f2c8c310f4a93df8fc8f6b75927442.yml"
}
 ❌  service1-ecs-cdk-dev-us-west-2 failed: ValidationError: Parameter values specified for a template which does not require them.
Parameter values specified for a template which does not require them.
ValidationError: Parameter values specified for a template which does not require them.
    at Request.extractError (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/protocol/query.js:50:29)
    at Request.callListeners (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:685:12)
    at Request.callListeners (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:116:18)

Here the main service1-ecs-cdk-dev-us-west-2 stack:

{
  "Resources": {
    "Service1Cluster200D5793": {
      "Type": "AWS::ECS::Cluster",
      "Properties": {
        "ClusterName": "service1-cdk-dev"
      },
      "Metadata": {
        "aws:cdk:path": "service1-ecs-cdk-dev-us-west-2/Service1Cluster/Resource"
      }
    }
  }
}

Expected behavior

No parameters on the service1-ecs-cdk-dev-us-west-2 stack.

Version:

  • Mac OS 10.14.5
  • Typescript
  • 0.34.0 (build 523807c)
@bigluck bigluck added the bug This issue is a bug. label Jun 18, 2019
@NGL321 NGL321 added the needs-triage This issue or PR still needs to be triaged. label Jun 18, 2019
@NGL321 NGL321 added @aws-cdk/core Related to core CDK functionality needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels Jun 26, 2019
@eladb eladb self-assigned this Aug 12, 2019
@dpllpd
Copy link

dpllpd commented Aug 17, 2019

Looks as if I'm having a similar problem. I only have one global dynamodb table in my stack. It seems that the table itself is created, properly. It runs two stacks to do that - one for each region. Then it tries to create service roles and policies along with custom resources. It succeeds. Then I see this:

Outputs:
dliefcapacity1dliefcdkdynamotablecapacitymetadatatab2CustomResource0BEB214E.ExportsOutputFnGetAttSingletonLambdaD38B65A66B544FB69BAD9CD40A6DAC1233FDC96AArn6F6A1622 = arn:aws:lambda:us-east-1:572724207364:function:dliefcapacity1dliefcdkdyn-SingletonLambdaD38B65A66-1B7SL0TD75XT9
dliefcapacity1dliefcdkdynamotablecapacitymetadatatab2CustomResource0BEB214E.ExportsOutputRefSingletonLambdaD38B65A66B544FB69BAD9CD40A6DAC12ServiceRoleD96868108A418CDD = dliefcapacity1dliefcdkdyn-SingletonLambdaD38B65A66-A89C1H48VDQR
dliefcapacity1dliefcdkdynamotablecapacitymetadatatab2CustomResource0BEB214E.ExportsOutputRefSingletonLambdaD38B65A66B544FB69BAD9CD40A6DAC12CodeS3VersionKey59DB89A029C34C64 = assets/dliefcapacity1dliefcdkdynamotablecapacitymetadatatab2CustomResourceSingletonLambdaD38B65A66B544FB69BAD9CD40A6DAC12CodeECA4552B/||d8f8c030c9b539854af097630a8008507efa891642b373314c13be745e601464.zip
dliefcapacity1dliefcdkdynamotablecapacitymetadatatab2CustomResource0BEB214E.ExportsOutputFnGetAttSingletonLambdaD38B65A66B544FB69BAD9CD40A6DAC12ServiceRoleD9686810ArnAA12755B = arn:aws:iam::572724207364:role/dliefcapacity1dliefcdkdyn-SingletonLambdaD38B65A66-A89C1H48VDQR
dliefcapacity1dliefcdkdynamotablecapacitymetadatatab2CustomResource0BEB214E.ExportsOutputRefAWSURLSuffix20C345A7 = amazonaws.com
dliefcapacity1dliefcdkdynamotablecapacitymetadatatab2CustomResource0BEB214E.ExportsOutputRefSingletonLambdaD38B65A66B544FB69BAD9CD40A6DAC12CodeS3BucketF66FB5434DE98180 = cdktoolkit-stagingbucket-1g5es3u3c5qr8

Stack ARN:
arn:aws:cloudformation:us-east-1:572724207364:stack/dliefcapacity1dliefcdkdynamotablecapacitymetadatatab2CustomResource0BEB214E/b27c4e80-c092-11e9-8a66-0abba1914a70
dlief-capacity1
dlief-capacity1: deploying...
dlief-capacity1: creating CloudFormation changeset...

❌ dlief-capacity1 failed: ValidationError: Parameter values specified for a template which does not require them.
Parameter values specified for a template which does not require them.

@dpllpd
Copy link

dpllpd commented Aug 18, 2019

This code will do it :

import cdk = require("@aws-cdk/core");
import { AttributeType } from "@aws-cdk/aws-dynamodb";
import { GlobalTable } from "@aws-cdk/aws-dynamodb-global";

class GlobalStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    new GlobalTable(this, "dlief-globdynamodb5", {
      partitionKey: { name: "hashKey", type: AttributeType.STRING },
      tableName: "dlief-GlobalTable1",
      regions: ["us-east-1", "us-west-2"]
    });
  }
}

const app = new cdk.App();
new GlobalStack(app, "dlief-capacity5");

app.synth();

@eladb eladb assigned skinny85 and unassigned eladb Oct 16, 2019
@eladb
Copy link
Contributor

eladb commented Oct 16, 2019

This is caused by a bug in how asset metadata is recorded when a sibling stack is defined as a child of another stack (not a nested stack):

const parent = new Stack(app, 'parent');
const child = new Stack(parent, 'child');
new Asset(child, 'my-asset', { path });

The resulting manifest indicates that both parent and child have an asset, which causes the CLI to try to wire the assets to the parent.

eladb pushed a commit that referenced this issue Oct 16, 2019
When synthesizes the metadata section of a stack in the cloud assembly
manifest, we traverse the tree below the stack and collect the metadata
associated with all nodes in this tree. If this tree has a child stack,
we don't need to collect the metadata from it's node, because they would
appear in the metadata of that child stack.

Metadata annotated on nested stack nodes will be recorded by the
first non-nested stack parent.

Specifically this bug caused an issue when the child stack used assets.
Currently assets are reported through assembly metadata on the stack,
and they would be reported both on the child and on the parent (although
the CloudFormation parameters of the assets would not appear on the parent).
This resulted in a CloudFormation error that reads:

    ValidationError: Parameter values specified for a template which does not require them.

Therefore this fixes #2900
@eladb
Copy link
Contributor

eladb commented Oct 16, 2019

Fix in: #4540

@mergify mergify bot closed this as completed in #4540 Oct 17, 2019
mergify bot pushed a commit that referenced this issue Oct 17, 2019
* fix(core): child stack assembly metadata is duplidated on parent

When synthesizes the metadata section of a stack in the cloud assembly
manifest, we traverse the tree below the stack and collect the metadata
associated with all nodes in this tree. If this tree has a child stack,
we don't need to collect the metadata from it's node, because they would
appear in the metadata of that child stack.

Metadata annotated on nested stack nodes will be recorded by the
first non-nested stack parent.

Specifically this bug caused an issue when the child stack used assets.
Currently assets are reported through assembly metadata on the stack,
and they would be reported both on the child and on the parent (although
the CloudFormation parameters of the assets would not appear on the parent).
This resulted in a CloudFormation error that reads:

    ValidationError: Parameter values specified for a template which does not require them.

Therefore this fixes #2900

* remove unused import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. needs-reproduction This issue needs reproduction.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants