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
#!/bin/bash | |
## More information about this process can be found at | |
## https://docs.aws.amazon.com/cloud9/latest/user-guide/move-environment.html#move-environment-resize | |
# Specify the desired volume size in GiB as a command line argument. If not specified, default to 20 GiB. | |
SIZE=${1:-20} | |
# Get the ID of the environment host Amazon EC2 instance. | |
INSTANCEID=$(curl http://169.254.169.254/latest/meta-data/instance-id) |
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
pip3 install --user --upgrade boto3 | |
export instance_id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) | |
python -c "import boto3 | |
import os | |
from botocore.exceptions import ClientError | |
ec2 = boto3.client('ec2') | |
volume_info = ec2.describe_volumes( | |
Filters=[ | |
{ | |
'Name': 'attachment.instance-id', |
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 PIL import Image | |
from sympy import isprime | |
import math | |
def ulam_spiral(length: int, start_num: int = 1) -> list[list[int]]: | |
""" | |
ulam_spiral plots the spiral of Ulam on a square with a side length of | |
the inputed length. | |
The result is returned in the coordinates of a two-dimensional array. |
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
#!/bin/bash -eu | |
# Auth アカウントのIAM ユーザ アクセスキーにより、get-session-token を実行して、MFA 認証済みの一時的認証情報を入手する | |
credentials=$(aws sts get-session-token \ | |
--serial-number arn:aws:iam::<auth_account_id>:mfa/<iam_username> \ | |
--token-code $1 \ | |
--query "Credentials.[AccessKeyId, SecretAccessKey,SessionToken]" \ | |
--output text) | |
# 一旦環境変数にMFA 認証済み一時的認証情報をセット | |
export AWS_ACCESS_KEY_ID=$(echo $credentials | cut -d ' ' -f 1) |
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
// JavaScript の非同期処理を理解するためのサンプル | |
const getThisYear = (callback) => { | |
setTimeout(() => callback(null, new Date().getFullYear()), 100); | |
} | |
const getNextYear = (year, callback) => { | |
setTimeout(() => callback(null, ++year), 100); | |
} |
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": [ | |
{ | |
"Sid": "AllowPolicy", | |
"Effect": "Allow", | |
"Action": [ | |
"ec2:*", | |
"autoscaling:*" | |
], |
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
#!/bin/bash | |
OPERATION_REGION=us-east-1 | |
ROLE_NAME=OrganizationAccountAccessRole | |
#Change your master account id | |
MASTAR_ACCOUNT_ID=<YOUR_MASTER_ACCOUNT_ID> | |
regions=$(aws ec2 describe-regions --query "Regions[].RegionName" --region $OPERATION_REGION --output text) | |
function delete_detector () { | |
region=$1 |
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
#!/bin/bash | |
OPERATION_REGION=us-east-1 | |
ROLE_NAME=OrganizationAccountAccessRole | |
#Change your master account id | |
MASTAR_ACCOUNT_ID=<YOUR_MASTER_ACCOUNT_ID> | |
regions=$(aws ec2 describe-regions --query "Regions[].RegionName" --region $OPERATION_REGION --output text) | |
function switch_role () { | |
account_id=$1 |
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
AWSTemplateFormatVersion: 2010-09-09 | |
Description: Enable AWS Config | |
Parameters: | |
AuditS3BucketName: | |
Type: String | |
OrganizationId: | |
Type: String | |
Resources: | |
ServiceLinkedRoleForConfig: |
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
WSTemplateFormatVersion: 2010-09-09 | |
Description: Create S3 Bucket for Config | |
Parameters: | |
AuditS3BucketName: | |
Type: String | |
OrganizationId: | |
Type: String | |
Resources: |
NewerOlder