$ aws --region=ap-northeast-2 ec2 describe-spot-price-history --instance-types c4.large --start-time=$(date +%s) --product-descriptions="Linux/UNIX" --query 'SpotPriceHistory[*].{az:AvailabilityZone, price:SpotPrice}'
[
{
"price": "0.024900",
"az": "ap-northeast-2a"
},
{
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
# watch the demo at https://youtu.be/cGUNf1FMNvI | |
# | |
# customize these variables | |
# | |
DEFAULT_PROFILE='default' | |
DEFAULT_REGION='us-east-1' | |
DEFAULT_OUTPUT='json' | |
SSO_START_URL='https://your-sso.awsapps.com/start' | |
SSO_REGION='us-east-1' | |
SSO_ACCOUNT_ID='123456789012' |
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
#!/bin/bash | |
# video demo - https://www.youtube.com/watch?v=Y8TyE_DNds8 | |
mkdir ~/.tmp && cd $_ | |
# install aws-cli v2 | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \ | |
unzip awscliv2.zip && \ | |
sudo ./aws/install |
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
#!/bin/bash | |
az=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone) | |
region=${az%%?} | |
instance_id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) | |
aws ec2 create-tags --resources $instance_id --region $region --tags \ | |
Key=foo,Value=bar \ | |
Key=Name,Value=myname |
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
# export the task def | |
family='TaskDefName' | |
$ aws ecs describe-task-definition --task-definition $family \ | |
--query "taskDefinition.{family:family, taskRoleArn:taskRoleArn, executionRoleArn:executionRoleArn, networkMode:networkMode, containerDefinitions:containerDefinitions, volumes:volumes, placementConstraints:placementConstraints, requiresCompatibilities:requiresCompatibilities, cpu:cpu, memory:memory, tags:tags, pidMode:pidMode, ipcMode:ipcMode, proxyConfiguration:proxyConfiguration}" | jq 'del(.[] | nulls)' > taskDef.json | |
# import the task def into newFamily task family | |
$ aws ecs register-task-definition --cli-input-json file://taskDef.json --family newFamily | |
# one-liner | |
aws ecs describe-task-definition --task-definition $family \ |
-
Open a new Amazon Linux 2 EC2(amd64) on AWS. Make it spot instance if you prefer.
ssh ec2-user@<EC2_IP> into the EC2 instance:
# install and start docker
$ sudo yum install -y docker
$ sudo service docker start
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
#!/usr/bin/env python | |
import boto3 | |
client = boto3.client('waf-regional', region_name='us-east-1') | |
ipSetId='<YOUR_IP_SET_ID>' | |
def getChangeToken(): | |
response = client.get_change_token() |
export AWS_DEFAULT_REGION=ap-northeast-1
aws logs describe-log-groups --query 'logGroups[*].logGroupName' --output table | \
awk '{print $2}' | grep -v ^$ | while read x; do echo "deleting $x" ; aws logs delete-log-group --log-group-name $x; done
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
#!/bin/sh | |
kubectl --namespace=kube-system get po | |
helm upgrade --install --create-namespace -n nginx my-nginx oci://registry-1.docker.io/bitnamicharts/nginx | |
kubectl --namespace=nginx get po |
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
workflow "Demo workflow" { | |
on = "push" | |
resolves = ["SNS Notification"] | |
} | |
action "Build Image" { | |
uses = "actions/docker/cli@c08a5fc9e0286844156fefff2c141072048141f6" | |
runs = ["/bin/sh", "-c", "docker build -t $IMAGE_URI ."] | |
env = { | |
IMAGE_URI = "xxxxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/github-action-demo:latest" |
NewerOlder