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

CDK deploy is not updating the changes to IAM statement policy #3538

Closed
1 of 5 tasks
harmohan-a opened this issue Aug 5, 2019 · 3 comments
Closed
1 of 5 tasks

CDK deploy is not updating the changes to IAM statement policy #3538

harmohan-a opened this issue Aug 5, 2019 · 3 comments
Assignees
Labels
investigating This issue is being investigated and/or work is in progress to resolve the issue. package/tools Related to AWS CDK Tools or CLI

Comments

@harmohan-a
Copy link

harmohan-a commented Aug 5, 2019

Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository's issues are intended for feature requests and bug reports.

  • I'm submitting a ...

    • 🪲 bug report
    • 🚀 feature request
    • 📚 construct library gap
    • ☎️ security issue or vulnerability => Please see policy
    • ❓ support request => Please see note at the top of this template.
  • What is the current behavior?
    If the current behavior is a 🪲bug🪲: Please provide the steps to reproduce

I had cdk stack that included, appsync, lambda, dax, dynamo. I updated the stack by granting permission on the table to the lambda

dynamoTable.grantReadWriteData(lambdaFunction);
doing a cdk diff shows the changes

Screen Shot 2019-08-05 at 3 40 20 pm

when i do, cdk deploy, i get the deploying... message but nothing actually happens

Do you wish to deploy these changes (y/n)? y
DaxDdbApiCdkStack: deploying...
harmohan:dax-ddb-api-cdk administrator$ 
  • What is the expected behavior (or behavior of feature suggested)?

cdk deploy should update the iam policy

  • What is the motivation / use case for changing the behavior or adding this feature?

  • Please tell us about your environment:

    • CDK CLI Version: 1.3.0
    • Module Version: 1.3.0
    • OS: [all | Windows 10 | OSX Mojave | Ubuntu | etc... ]
    • Language: TypeScript
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)

@harmohan-a harmohan-a added the needs-triage This issue or PR still needs to be triaged. label Aug 5, 2019
@nmussy
Copy link
Contributor

nmussy commented Aug 9, 2019

I haven't been able to reproduce your issue with what you've described. I've created the following stack:

const table = new Table(this, 'table', {
    partitionKey: { name: 'id', type: AttributeType.STRING }
});

const lambda = new Function(this, 'function', {
    runtime: Runtime.NODEJS_8_10,
    handler: 'index.handler',
    code: Code.inline('exports.handler = () => { return cb(null, "test"); }'),
});

Deploying that stack, and then adding table.grantReadWriteData(lambda); works fine:

>npx cdk diff
Stack DynamoTestStack
IAM Statement Changes
┌───┬───────────────┬────────┬───────────────────────────────────────────┬───────────────────────────────────────────┬───────────┐
│   │ Resource      │ Effect │ Action                                    │ Principal                                 │ Condition │
├───┼───────────────┼────────┼───────────────────────────────────────────┼───────────────────────────────────────────┼───────────┤
│ + │ ${table.Arn}  │ Allow  │ dynamodb:BatchGetItem                     │ AWS:${function/ServiceRole}               │           │
│   │               │        │ dynamodb:BatchWriteItem                   │                                           │           │
│   │               │        │ dynamodb:DeleteItem                       │                                           │           │
│   │               │        │ dynamodb:GetItem                          │                                           │           │
│   │               │        │ dynamodb:GetRecords                       │                                           │           │
│   │               │        │ dynamodb:GetShardIterator                 │                                           │           │
│   │               │        │ dynamodb:PutItem                          │                                           │           │
│   │               │        │ dynamodb:Query                            │                                           │           │
│   │               │        │ dynamodb:Scan                             │                                           │           │
│   │               │        │ dynamodb:UpdateItem                       │                                           │           │
└───┴───────────────┴────────┴───────────────────────────────────────────┴───────────────────────────────────────────┴───────────┘
(NOTE: There may be security-related changes not in this list. See http://bit.ly/cdk-2EhF7Np)

Resources
[+] AWS::IAM::Policy function/ServiceRole/DefaultPolicy functionServiceRoleDefaultPolicy5ACF569A
[~] AWS::Lambda::Function function functionF19B1A04
 └─ [~] DependsOn
     └─ @@ -1,3 +1,4 @@
        [ ] [
        [+]   "functionServiceRoleDefaultPolicy5ACF569A",
        [ ]   "functionServiceRoleEF216095"
        [ ] ]
> npx cdk deploy
This deployment will make potentially sensitive changes according to your current security approval level (--require-approval broad
ening).
Please confirm you intend to make the following modifications:

IAM Statement Changes
┌───┬───────────────┬────────┬───────────────────────────────────────────┬───────────────────────────────────────────┬───────────┐
│   │ Resource      │ Effect │ Action                                    │ Principal                                 │ Condition │
├───┼───────────────┼────────┼───────────────────────────────────────────┼───────────────────────────────────────────┼───────────┤
│ + │ ${table.Arn}  │ Allow  │ dynamodb:BatchGetItem                     │ AWS:${function/ServiceRole}               │           │
│   │               │        │ dynamodb:BatchWriteItem                   │                                           │           │
│   │               │        │ dynamodb:DeleteItem                       │                                           │           │
│   │               │        │ dynamodb:GetItem                          │                                           │           │
│   │               │        │ dynamodb:GetRecords                       │                                           │           │
│   │               │        │ dynamodb:GetShardIterator                 │                                           │           │
│   │               │        │ dynamodb:PutItem                          │                                           │           │
│   │               │        │ dynamodb:Query                            │                                           │           │
│   │               │        │ dynamodb:Scan                             │                                           │           │
│   │               │        │ dynamodb:UpdateItem                       │                                           │           │
└───┴───────────────┴────────┴───────────────────────────────────────────┴───────────────────────────────────────────┴───────────┘
(NOTE: There may be security-related changes not in this list. See http://bit.ly/cdk-2EhF7Np)

Do you wish to deploy these changes (y/n)? y
DynamoTestStack: deploying...
DynamoTestStack: creating CloudFormation changeset...
 0/2 | 3:38:42 PM | CREATE_IN_PROGRESS   | AWS::IAM::Policy      | function/ServiceRole/DefaultPolicy (functionServiceRoleDefaultPolicy5ACF569A)
 0/2 | 3:38:44 PM | CREATE_IN_PROGRESS   | AWS::IAM::Policy      | function/ServiceRole/DefaultPolicy (functionServiceRoleDefaultPolicy5ACF569A) Resource creation Initiated
 1/2 | 3:38:52 PM | CREATE_COMPLETE      | AWS::IAM::Policy      | function/ServiceRole/DefaultPolicy (functionServiceRoleDefaultPolicy5ACF569A)
 1/2 | 3:38:58 PM | UPDATE_COMPLETE_CLEA | AWS::CloudFormation::Stack | DynamoTestStack
 2/2 | 3:38:58 PM | UPDATE_COMPLETE      | AWS::CloudFormation::Stack | DynamoTestStack

 ✅  DynamoTestStack

Could you give us additional details about your stack to help understand what's blocking the second deployment?

@eladb eladb added package/tools Related to AWS CDK Tools or CLI investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Aug 13, 2019
@harmohan-a
Copy link
Author

Hi, initially when it wasn't working I update the lambda code and the deployment worked fine. i thought that was the work around. But, I've been trying to re-create the same issue since morning and I cant.

I'll close the ticket. Thanks for having a look at it. and sorry for wasting your time

@nmussy
Copy link
Contributor

nmussy commented Aug 15, 2019

No problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigating This issue is being investigated and/or work is in progress to resolve the issue. package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests

4 participants