This file contains 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 argparse | |
parser = argparse.ArgumentParser(prog=__file__) | |
parser._action_groups.pop() # Edited this line | |
required = parser.add_argument_group('required arguments') | |
optional = parser.add_argument_group('optional arguments') | |
required.add_argument('--group-name',required=True,help='The name of the IAM group to delete.') | |
optional.add_argument('--profile',nargs='?',default='default',help='Use a specific profile from your credential file.') |
This file contains 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 argparse | |
parser = argparse.ArgumentParser(prog=__file__) | |
parser._action_groups.pop() # Edited this line | |
required = parser.add_argument_group('required arguments') | |
optional = parser.add_argument_group('optional arguments') | |
required.add_argument('--role-name',required=True,help='The name of the role to delete.') | |
optional.add_argument('--profile',nargs='?',default='default',help='Use a specific profile from your credential file.') |
This file contains 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 requests | |
import lxml.html | |
html = requests.get('https://www.kabegiwablog.com').text | |
root = lxml.html.fromstring(html) | |
max_blog_post_count = 15 | |
for i in range(1,max_blog_post_count): | |
blog_post = root.xpath('/html/body/div[3]/div/div[2]/div/div/div/div/div[1]/section['+str(i)+']/div[1]/h1/a') | |
print(blog_post[0].text+'\n'+blog_post[0].attrib['href']+'\n') |
This file contains 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 re, requests, sys, io | |
from bs4 import BeautifulSoup | |
from datetime import datetime | |
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') | |
def whats_new_current_month(): | |
current_year = "{0:02d}".format(datetime.now().year) | |
current_month = "{0:02d}".format(datetime.now().month) | |
whats_new_url = 'aws.amazon.com/jp/about-aws/whats-new/'+current_year+'/'+current_month+'/' |
This file contains 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 argparse | |
parser = argparse.ArgumentParser(prog='profile.py') | |
parser.add_argument('--profile',nargs='?',default='default',help='Use a specific profile from your credential file.') | |
args = parser.parse_args() | |
profile = args.profile | |
session = boto3.Session(profile_name=profile) |
This file contains 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 requests | |
from bs4 import BeautifulSoup | |
from datetime import datetime | |
current_year = datetime.now().year | |
current_month = datetime.now().month | |
url = 'https://aws.amazon.com/jp/about-aws/whats-new/'+"{0:02d}".format(current_year)+'/'+"{0:02d}".format(current_month)+'/' | |
request = requests.get(url) | |
soup = BeautifulSoup(request.text, 'lxml') |
This file contains 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 | |
session = boto3.Session(profile_name='wawawa_test_role') | |
sts = session.client('sts') | |
print(sts.get_caller_identity()) |
This file contains 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 | |
sts = boto3.client('sts') | |
iam_role_arn = 'arn:aws:iam::123456789012:role/wawawa_role' | |
response = sts.assume_role( | |
RoleArn=iam_role_arn, | |
RoleSessionName='wawawa' | |
) |
This file contains 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 pathlib import Path | |
iam = boto3.client('iam') | |
sts = boto3.client('sts') | |
def get_old_key_id(): | |
old_access_key_id = iam.list_access_keys()['AccessKeyMetadata'][0]['AccessKeyId'] |
This file contains 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 | |
iam = boto3.client('iam') | |
sts = boto3.client('sts') | |
access_key_id = iam.list_access_keys()['AccessKeyMetadata'][0]['AccessKeyId'] | |
response = sts.get_caller_identity() | |
user_name = response['Arn'].split('/')[1] |