question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(aws-sam): cannot generate string policies for CfnFunction

See original GitHub issue

The property CfnFunctionProps.policies accepts a list of both objects and strings. However, when I try to generate a list with a string, an empty object is generated instead.

Reproduction Steps

Running cdk synth with the following construct:

new CfnFunction(scope, 'MyFunction', {
  policies: ['AWSLambdaExecute']
});

What did you expect to happen?

  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      Policies:
        - AWSLambdaExecute

What actually happened?

  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      Policies:
        - {}

Environment

  • CDK CLI Version : 1.80.0
  • Framework Version:
  • Node.js Version: 12.18.3
  • OS : Ubuntu 19.10
  • Language (Version):

Other

Note that if I use a string, instead of a list of strings, the output is correct.

new CfnFunction(scope, 'MyFunction', {
  policies: 'AWSLambdaExecute'
});
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      Policies: 'AWSLambdaExecute'

This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
skinny85commented, Feb 3, 2021

Which means we need to make sure that a string is not a valid object in our validation logic.

0reactions
github-actions[bot]commented, Feb 12, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

class CfnFunction (construct) · AWS CDK - AWS Documentation
Create a new AWS::Serverless::Function . Construct Props. Name, Type, Description. architectures? string[], AWS ...
Read more >
Reference local code in SAM using CfnFunction in the CDK ...
Where hello_world has the code for my function. Running sam build and sam deploy does the work of packaging and uploading the code...
Read more >
Top 5 @aws-cdk/aws-sam Code Examples - Snyk
To help you get started, we've selected a few @aws-cdk/aws-sam examples, based on popular ways it is used in public projects.
Read more >
awssam - Go Packages
Construct, id *string, props *CfnFunctionProps) CfnFunction ... The Removal Policy controls what happens to this resource when it stops // being managed by ......
Read more >
Mastering the AWS Serverless Application Model (AWS SAM)
When building serverless applications, you have a wide range of options for building your infrastructure and developing your code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found