Skip to content

Feature Request: New SAM type of AWS::Serverless::FunctionRole #562

@rmmeans

Description

@rmmeans

Description:

SAM's ability to dynamically generate least-privilege function roles using SAM Policy templates is an extremely valuable feature. However, it presumes that the deployment pipelines that are deploying the SAM templates have the necessary IAM permissions for the pipeline itself to create IAM Roles vs passing a given role to the function.

I would like to propose a new top level type within SAM - a type that creates the same role that AWS::Serverless::Function creates when using SAM policy templates, but that is it. This would allow organizations that separate the controls around IAM management from general AWS resource management (e.g. Lambda Functions, etc) to still be able to use the power of SAM Policy Templates within a stack that only creates IAM roles.

Proposal:


AWS::Serverless::FunctionRole

Creates an IAM execution Role for AWS Lambda using names of AWS managed IAM policies or IAM policy documents or SAM Policy Templates that this function needs, which will be appended to the default role created by SAM for Lambda Functions.

Properties
Property Name Type Description
RoleName string The name of the Role.
Policies string | List of string | IAM policy document object | List of IAM policy document object | List of SAM Policy Templates Required. Names of AWS managed IAM policies or IAM policy documents or SAM Policy Templates that this function needs, which should be appended to the default role for this function.
Tracing boolean Indicates if this role should have access to make XRAY service calls. Enable if your Function is configured to use Tracing.
Return values
Ref

When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the resource name of the underlying IAM Role.

Fn::GetAtt

When the logical ID of this resource is specified to the Fn::GetAtt intrinsic function, it returns a value for a specified attribute of this type. This section lists the available attributes.

Attribute Name Description
Arn Returns the Amazon Resource Name (ARN) for the role.
RoleId Returns the stable and unique string identifying the role. For example, AIDAJQABLZS4A3QDU576Q.
Example: AWS::Serverless::FunctionRole
Resources:
  MyLambdaFunctionRole:
    Type: AWS::Serverless::FunctionRole
    Properties:
      Policies: 
        - DynamoDBCrudPolicy:
            TableName: MyDynamoTableName
        - Version: '2012-10-17' # Policy Document
          Statement:
            - Effect: Allow
              Action:
                - s3:GetObject
                - s3:GetObjectACL
              Resource: 'arn:aws:s3:::my-bucket/*'
      Tracing: true

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions