Skip to content

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

@spalladino

Description

@spalladino

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

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-samRelated to AWS Serverless Application ModelguidanceQuestion that needs advice or information.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions