aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.58k stars 3.88k forks source link

(redshift): modifyClusterIamRoles with unexpected key 'DefaultIamRoleArn' found in params #18186

Closed clementy-aws closed 2 years ago

clementy-aws commented 2 years ago

What is the problem?

The Lambda code

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0

const AWS = require('aws-sdk');
const redshift = new AWS.Redshift();

exports.handler = async event => {
    const clusterId = event.ResourceProperties.ClusterIdentifier;
    const roleArn = event.ResourceProperties.RoleArn;

    var data = await redshift.describeClusters({ ClusterIdentifier: clusterId }).promise();
    if (data.Clusters.length != 1) {
        throw new Error(`Unable to find cluster ${clusterId}`);
    }

    console.log(`Set this role as default ${roleArn}`)
    await redshift.modifyClusterIamRoles({
         ClusterIdentifier: clusterId,
         DefaultIamRoleArn: roleArn
    }).promise();
    console.log(`Cluster ${clusterId} default role set.`)
};

The error log:

Reason: "UnexpectedParameter: Unexpected key 'DefaultIamRoleArn' found in params\n" +
    '    at ParamValidator.fail (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:50:37)\n' +
    '    at ParamValidator.validateStructure (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:77:14)\n' +
    '    at ParamValidator.validateMember (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:88:21)\n' +
    '    at ParamValidator.validate (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:34:10)\n' +
    '    at Request.VALIDATE_PARAMETERS (/var/runtime/node_modules/aws-sdk/lib/event_listeners.js:132:42)\n' +
    '    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)\n' +
    '    at callNextListener (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:96:12)\n' +
    '    at /var/runtime/node_modules/aws-sdk/lib/event_listeners.js:86:9\n' +
    '    at finish (/var/runtime/node_modules/aws-sdk/lib/config.js:386:7)\n' +
    '    at /var/runtime/node_modules/aws-sdk/lib/config.js:404:9',

Also tried the following CLI:

aws redshift modify-cluster-iam-roles \
--cluster-identifier ${CLUSTER_ID} \
--default-iam-role-arn ${ROLE_ARN}

It complains:

Unknown options: --default-iam-role-arn, 

Where I have:

clementy@ cdk-redshift % aws --version
aws-cli/2.2.42 Python/3.8.8 Darwin/20.6.0 exe/x86_64 prompt/off

Reproduction Steps

As explained in the above section.

What did you expect to happen?

The default role of redshift should be properly set.

What actually happened?

See the exception in the first section.

CDK CLI Version

2.3.0

Framework Version

No response

Node.js Version

v16.10.0

OS

macOS 11.6.2

Language

Typescript

Language Version

Javascript

Other information

No response

ryparker commented 2 years ago

This is a bug of the SDK not CDK (Cloud Development Kit). CDK is a CloudFormation template generator. Report an issue with aws-sdk here

github-actions[bot] commented 2 years ago

⚠️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.