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-iam: policy statements are trying to validate tokens #13479

Assignees
Labels
@aws-cdk/aws-iam Related to AWS Identity and Access Management bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md needs-triage This issue or PR still needs to be triaged. p2

Comments

@cheng-kevin
Copy link

cheng-kevin commented Mar 8, 2021

❓ General Issue

Are IAM PolicyDocument Actions limited to string types? I am trying to reference a cloudformation parameter as my action.

 new iam.PolicyStatement({
      actions: [
         core.Fn.join('',
          [ core.Fn.ref(Parameters.myparameter, ':*' )]
      ],
      effect: iam.Effect.ALLOW,
      resources: [ '*' ] 
    }
)

The Question

Environment

  • CDK CLI Version:
  • Module Version:
  • Node.js Version:
  • OS:
  • Language (Version):

Other information

@cheng-kevin cheng-kevin added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Mar 8, 2021
@cheng-kevin cheng-kevin changed the title (module name): short issue description aws-iam: Are actions limited to string type? Mar 8, 2021
@github-actions github-actions bot added the @aws-cdk/aws-iam Related to AWS Identity and Access Management label Mar 8, 2021
@skinny85
Copy link
Contributor

skinny85 commented Mar 9, 2021

Hey @cheng-kevin ,

looks like you're right - while usually in the CDK you can do things like:

        const myParameter = new cdk.CfnParameter(this, 'Param');
        new iam.PolicyStatement({
                actions: [
                    `${myParameter.value}:*`,
                ],
                effect: iam.Effect.ALLOW,
                resources: [ '*' ]
            }
        );

This results in the following error:

Action '${Token[Param.Ref.20]}:*' is invalid. An action string consists of a service namespace, a colon, and the name of an action. Action names can include wildcards.

Probably this code should check if action is a Token using the Token.isUnresolved() method.

@rix0rrr rix0rrr added bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p2 and removed guidance Question that needs advice or information. labels Mar 9, 2021
@rix0rrr rix0rrr changed the title aws-iam: Are actions limited to string type? aws-iam: policy statements are trying to validate tokens Mar 9, 2021
@rix0rrr
Copy link
Contributor

rix0rrr commented Mar 9, 2021

What @skinny85 said is accurate

@mergify mergify bot closed this as completed in #13493 Mar 10, 2021
mergify bot pushed a commit that referenced this issue Mar 10, 2021
Looking for guidance on error messaging and/or docs to update
Fixes #13479

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@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.

This was referenced Mar 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment