Replies: 8 comments
-
Is it primarily Policy Templates that you're interested in exposing at a higher level? |
Beta Was this translation helpful? Give feedback.
-
Yes mostly. We want the full power of the Policy templates combined with lists of policy documents and lists of Managed Policies to create IAM roles for Lambda Functions. We plan on using this exactly like in my example of combining policy templates along with lists of policy documents that a given lambda function needs. The only reason I included the Our end goal is such that Developers who understand SAM's syntax can request the exact same role that SAM would have created for them under a Because no such capability exists in core CloudFormation - that means our developers and other team members must always craft the correct least privilege role for everything their function needs to use as raw CloudFormation. Having the ability to do exactly what SAM does here, but only to create the role itself would be a huge win for both the developers requesting roles as well as the folks reviewing requests for roles. |
Beta Was this translation helpful? Give feedback.
-
I'm onboard with surfacing something like this.
In case it's useful to you, you can access the underlying role created for you by SAM by its logical resource ID as documented here https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#aws-serverless-function. For example, a Function with the logical resource id of |
Beta Was this translation helpful? Give feedback.
-
With the launch of macro's, technically I could make a macro that would effectively accomplish what were after, I'm just weary of separating that from SAM itself as I really do want to create the exact same role SAM would have created for me, just as a first class type. I could easily get into a feature drift scenario where I was trying to avoid it if I created my own macro. |
Beta Was this translation helpful? Give feedback.
-
You certainly could take that approach, but the better approach would be to submit a PR. |
Beta Was this translation helpful? Give feedback.
-
Thanks! I rarely work with Python, so it might be rough. Before we consider hacking a macro together, we'll at least review taking a stab at a PR now that we know a new top level type would be welcome. |
Beta Was this translation helpful? Give feedback.
-
Yes, we're definitely open to new top-level types! I think a good first step for PR (and lower barrier to entry if you're unsure of python skills or the SAM translator internal logic), would be to submit a PR that updates the SAM spec itself and adds to the example templates showing the functionality you intend to support. This is a much easier way to start and helps get you feedback to solidify the intended behavior before you begin implementation. You've pretty much already defined these things in the issue request above, so it should be pretty easy to translate to a PR. |
Beta Was this translation helpful? Give feedback.
-
Agreed there should be an RFC before implementation begins. PR is one way to do that, with the biggest advantage being we have a history of the changes via commits. However, you already have the spec update and example in this Issue so we could just continue here, and I personally find it easier to edit an Issue (like I did with the Auth RFC). I'll leave it up to you to decide (if you choose to go this route) |
Beta Was this translation helpful? Give feedback.
-
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
string
string
| List ofstring
| IAM policy document object | List of IAM policy document object | List of SAM Policy Templatesboolean
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.
AIDAJQABLZS4A3QDU576Q
.Example: AWS::Serverless::FunctionRole
Beta Was this translation helpful? Give feedback.
All reactions