This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
# Configure your AWS credentials | |
aws_access_key_id = 'YOUR_ACCESS_KEY_ID' | |
aws_secret_access_key = 'YOUR_SECRET_ACCESS_KEY' | |
aws_region = 'us-east-1' # Replace with your desired AWS region | |
# Create a CodeDeploy client | |
codedeploy = boto3.client('codedeploy', region_name=aws_region, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"dynamodb:Describe*", | |
"dynamodb:Get*", | |
"dynamodb:List*", | |
"dynamodb:Batch*", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws iam create-user --user-name Mary |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
from botocore.exceptions import ClientError | |
bucket_name = "test-bucket" | |
folder_paths = ["test_folder","test_folder1", "test_folder2"] | |
expiration = 1 | |
def add_lifecycle_rule_for_s3(bucket_name,folder_paths): | |
session = boto3.session.Session() | |
s3_client = session.client('s3') | |
try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
aws_client = boto3.client('cognito-idp', | |
region_name = CONFIG["cognito"]["region"] | |
) | |
response = aws_client.admin_create_user( | |
UserPoolId = CONFIG["cognito"]["pool_id"], | |
Username = email, | |
UserAttributes = [ | |
{"Name": "first_name", "Value": first_name}, | |
{"Name": "last_name", "Value": last_name}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import boto | |
#boto.set_stream_logger('foo') | |
import json | |
client = boto3.client('cognito-identity','us-east-1') | |
resp = client.get_id(AccountId='<ACCNTID>',IdentityPoolId='<IDPOOLID>') | |
print "\nIdentity ID: %s"%(resp['IdentityId']) | |
print "\nRequest ID: %s"%(resp['ResponseMetadata']['RequestId']) | |
resp = client.get_open_id_token(IdentityId=resp['IdentityId']) | |
token = resp['Token'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from boto.s3.connection import S3Connection | |
from boto.sts import STSConnection | |
user = sts.get_federation_token('user1') | |
s3connection = S3Connection(user.credentials.access_key, user.credentials.secret_key, security_token=user.credentials.session_token) | |
s3connection.create_bucket('dev.professional') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response = client.list_attached_role_policies( | |
RoleName='string', | |
PathPrefix='string', | |
Marker='string', | |
MaxItems=123 | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def attach_group_policy(policy_arn, group_name): | |
iam = boto3.client("iam") | |
response = iam.attach_group_policy( | |
GroupName=group_name, | |
PolicyArn=policy_arn | |
) | |
print(response) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def list_policies(): | |
iam = boto3.client("iam") | |
paginator = iam.get_paginator('list_policies') | |
for response in paginator.paginate(Scope="AWS"): | |
for policy in response["Policies"]: | |
print(f"Policy Name: {policy['PolicyName']} ARN: {policy['Arn']}") |
NewerOlder