Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@sts_conn('iam', service_type='client')
@rate_limited()
def get_managed_policy_document(policy_arn, policy_metadata=None, client=None, **kwargs):
"""Retrieve the currently active (i.e. 'default') policy version document for a policy.
:param policy_arn:
:param policy_metadata: This is a previously fetch managed policy response from boto/cloudaux.
This is used to prevent unnecessary API calls to get the initial policy default version id.
:param client:
:param kwargs:
:return:
"""
if not policy_metadata:
policy_metadata = client.get_policy(PolicyArn=policy_arn)
policy_document = client.get_policy_version(PolicyArn=policy_arn,
VersionId=policy_metadata['Policy']['DefaultVersionId'])
@sts_conn('sqs')
@rate_limited()
def set_queue_attributes(client=None, **kwargs):
return client.set_queue_attributes(**kwargs)
@sts_conn('sns')
@rate_limited()
def delete_topic(client=None, **kwargs):
return client.delete_topic(**kwargs)
@sts_conn('ec2')
@rate_limited()
def create_group(group, account_number=None, region=None, assume_role=None, client=None):
if group.vpc_id:
group_id = client.create_security_group(
GroupName=group.name,
Description=group.description,
VpcId=group.vpc_id
)['GroupId']
else:
group_id = client.create_security_group(
GroupName=group.name,
Description=group.description
)['GroupId']
return group_id
@sts_conn('sns')
@paginated('Endpoints', request_pagination_marker="NextToken", response_pagination_marker="NextToken")
@rate_limited()
def list_endpoints_by_platform_application(client=None, **kwargs):
return client.list_endpoints_by_platform_application(**kwargs)
@sts_conn('sqs')
@rate_limited()
def send_message_batch(client=None, **kwargs):
return client.send_message_batch(**kwargs)
@sts_conn('sqs')
@rate_limited()
def get_queue_url(client=None, **kwargs):
return client.get_queue_url(**kwargs)['QueueUrl']
@sts_conn('ec2')
@rate_limited()
def authorize_rule(rule, group, account_number=None, region=None, assume_role=None, client=None):
if rule.direction == 'egress':
# response = client.authorize_security_group_egress()
raise CloudAuxException("Modifying egress rules is not yet supported.")
else:
if rule.cidr:
client.authorize_security_group_ingress(
GroupId=group.aws_group_id,
IpProtocol=rule.protocol,
FromPort=rule.from_port,
ToPort=rule.to_port,
CidrIp=rule.cidr
)
else:
client.authorize_security_group_ingress(
@sts_conn('ec2')
@rate_limited()
def describe_vpn_connections(**kwargs):
return kwargs.pop('client').describe_vpn_connections(**kwargs).get("VpnConnections", [])
@sts_conn('s3')
@rate_limited()
def list_buckets(client=None, **kwargs):
return client.list_buckets()