aws / aws/serverless-application-model

Make policy template allow logical id of resources

Open
#1,254 2 comments 12 reactions 0 assignees View on GitHub
area/policy-templates maintainer/need-followup type/feature
Dominant language
Python
Stars
9.6k
Forks
2.5k
Avg merge
1d 11h
Merged PRs (30d)
7

Description

When adding policy templates to functions one has to refer to the cloudformation documentation to find the correct intrinsic function to fetch the reference desired by the policy.

For example:
DynamoDBCrudPolicy requires a TableName that's exposed through `Ref`:
```
{
"DynamoDBCrudPolicy": {
"TableName": {
"Ref": "MyTable"
}
}
}
```

...but SNSPublishMessagePolicy expects a TopicName that's exposed via `GetAtt`:
```
{
"SNSPublishMessagePolicy": {
"TopicName": {
"Fn::GetAtt": [
"MyTopic",
"TopicName"
]
}
}
}
```

Would it be possible to somehow just provide the logical ID to the resource and let the policy template processor inject the correct intrinsic function for the resource?

Like this:
```
{
"DynamoDBCrudPolicy": {
"TableName": "MyTable"
}
}
```
...or maybe:
```
{
"DynamoDBCrudPolicy": {
"TableLogicalId": "MyTable"
}
}
```

[Here's a video ](https://www.dropbox.com/s/1dmk51tru6b6t6q/policy-template.mp4?dl=0) of what I'm trying to achieve. At the moment I'm defaulting the intrinsic function to `Ref`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.