Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
import boto3
iam = boto3.client('iam')
response = iam.list_groups()
group_name_list = [ response['GroupName'] for response in response['Groups'] ]
for group_name in group_name_list:
print(group_name)
import boto3
ec2 = boto3.client('ec2')
response = ec2.describe_instances()
instance_id_list = []
for reservations in response['Reservations']:
instance_id_list.append(reservations['Instances'][0]['InstanceId'])
print(instance_id_list)
@takakabe
takakabe / tag_switch_role_policy.json
Last active August 23, 2019 02:59
tag_switch_role_policy
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::*:role/*",
"Condition": {
"StringEquals": {
"iam:ResourceTag/environment": "dev"
}
@takakabe
takakabe / bmi.sh
Created March 8, 2019 04:28
check bmi
#!/bin/bash
height=${1}
weight=${2}
bmi=`echo "scale=6;(${weight} / ${height} ^2 * 10000)" | bc | awk '{print substr($1,0,5)}'`
echo ${bmi}
@takakabe
takakabe / arrest.sh
Last active March 8, 2019 01:42
mudamudamuda
#!/bin/bash
trap 'muda' SIGINT
function muda() {
while true; do
echo '何回閉じても無駄ですよ~'
sleep 1
done
}
@takakabe
takakabe / iam_policy.json
Created March 5, 2019 14:33
Create iampolicy with Ansible
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
}
@takakabe
takakabe / wait.sh
Created March 5, 2019 04:35
shellscript to wait for process
#!/bin/bash
sleep 5 &
sleep 6 &
sleep 4 &
wait
echo '待ち合わせ終わった'
@takakabe
takakabe / create_codepipeline.yml
Created March 1, 2019 06:58
Create Codepipeline
---
- name: Create codepipeline policy
iam_managed_policy:
policy_name: CodepipelinePolicy
policy: "{{ lookup('file','../meta/iam_policy.json') }}"
state: present
register: policy_result
- name: Create codepipeline Role
iam_role:
@takakabe
takakabe / create_codedeploy.yml
Created February 25, 2019 07:04
Create Codedeploy with Ansible
---
# use the AWS CLI to create a (default) parameter group for Aurora clusters
- name: Create a role and attach a managed policy called AWSCodeDeployRole
iam_role:
name: "{{ iam_role_name }}"
assume_role_policy_document: "{{ lookup('file','../meta/policy.json') }}"
managed_policy:
- arn:aws:iam::aws:policy/service-role/AWSCodeDeployRole
register: iam_role_result
@takakabe
takakabe / reboot.yml
Created February 20, 2019 11:45
Ansible
- hosts: localhost
tasks:
- reboot: