Skip to content

Instantly share code, notes, and snippets.

@tmaslen
Created November 29, 2013 16:05
Show Gist options
  • Save tmaslen/7707903 to your computer and use it in GitHub Desktop.
Save tmaslen/7707903 to your computer and use it in GitHub Desktop.
import BBC.AWS.CloudFormation
from BBC.AWS.CloudFormation import SQS, IAM
from BBC.AWS.CloudFormation.Common.ResourcePermissions import SQSActions
try: import json
except ImportError: import simplejson as json
template = BBC.AWS.CloudFormation.Template()
template.description = (
"Create a user for the foo service"
)
resource_name = template.parameter(
"SomeSqsArn",
param_type="String",
description="Resource ARN of SQS"
)
foo_policy = IAM.Policy("NewsVisJUserSomeQueue")
foo_policy.add_rule("sqs", "Allow", SQSActions.publish, arn=resource_name)
foo_user = IAM.User("NewsVisJ")
foo_user.add_policy(foo_policy)
template.attach(foo_user)
template.output(
"NewsVisJUser",
foo_user.id(),
"The user for NewsVisJ to be able to push to sqs"
)
print json.dumps(template.render(), indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment