Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for ElastiCacheRedis.py example to use awacs #725

Merged
merged 5 commits into from
Jun 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions examples/ElastiCacheRedis.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import troposphere.ec2 as ec2
import troposphere.elasticache as elasticache
import troposphere.iam as iam
import awacs

from awacs.aws import (Allow,
Statement,
Expand Down Expand Up @@ -262,31 +263,21 @@ def main():
]
),
Path='/',
))
))

template.add_resource(iam.PolicyType(
'WebServerRolePolicy',
PolicyName='WebServerRole',
# PolicyDocument=Policy(
# Statement=[
# Statement(
# Effect=Allow,
# Action=['elasticache:DescribeCacheClusters'],
# Resource=['*'],
# )
# ]
# )
# The following can probably be fixed to use #
# awacs (above didn't work) #
PolicyDocument={
"Statement": [{
"Effect": "Allow",
"Action": "elasticache:DescribeCacheClusters",
"Resource": "*"
}]
},
PolicyDocument=awacs.aws.Policy(
Statement=[awacs.aws.Statement(
Action=[awacs.aws.Action("elasticache",
"DescribeCacheClusters")],
Resource=["*"],
Effect=awacs.aws.Allow
)]
),
Roles=[Ref(webserverrole)],
))
))

webserverinstanceprofile = template.add_resource(iam.InstanceProfile(
'WebServerInstanceProfile',
Expand Down
8 changes: 6 additions & 2 deletions tests/examples_output/ElastiCacheRedis.template
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,13 @@
"PolicyDocument": {
"Statement": [
{
"Action": "elasticache:DescribeCacheClusters",
"Action": [
"elasticache:DescribeCacheClusters"
],
"Effect": "Allow",
"Resource": "*"
"Resource": [
"*"
]
}
]
},
Expand Down