Skip to content

Instantly share code, notes, and snippets.

View neilkuan's full-sized avatar
🎯
Focusing

Neil Kuan neilkuan

🎯
Focusing
View GitHub Profile
#!/bin/bash
##Color
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
## ENV
DEFAULT_REGION=us-west-2
ACCOUNT_ID=123456789012
AWS_REGION=${2-$DEFAULT_REGION}
   const vpc = new ec2.Vpc(this, 'testvpc', { natGateways: 1, cidr: '10.0.0.0/16' });
   const change = ['10.0.7.0/24', '10.0.8.0/24', '10.0.9.0/24'];
   for (let index = 0; index < change.length; index++) {
     ((vpc.node.findChild(`PublicSubnet${index + 1}`) as ec2.IPublicSubnet)
       .node.findChild('Subnet') as ec2.CfnSubnet)
       .addPropertyOverride('CidrBlock', change[index]);
   }
#!/bin/bash
#!/bin/bash
yum install docker -y
systemctl start docker
usermod -aG docker ec2-user
usermod -aG docker ssm-user
chmod +x /var/run/docker.sock
systemctl restart docker && systemctl enable docker
mkdir /home/ec2-user/jenkins-data
docker run --name jks --rm -d -u root -p 8080:8080 -p 50000:50000 -v /home/ec2-user/jenkins-data:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock -v /home/ec2-user:/home jenkinsci/blueocean
@neilkuan
neilkuan / aws-cli-tips.md
Last active August 10, 2021 13:25
AWS CLI Tips notes.

IAM STS

$ aws sts get-caller-identity --query  Arn
"arn:aws:iam::123456789012:user/neilguan"
$ aws sts get-caller-identity --query  Arn --output text
arn:aws:iam::123456789012:user/neilguan
$ aws sts get-caller-identity --query  Account --output text
123456789012
$ aws sts get-caller-identity --query  UserId --output text
AIXXXXXXXXXXXXXXXXXXXG
#!/bin/bash
#$1 put kms id.
#$2 put values.
aws kms encrypt --key-id "$1" --plaintext $2 --output text --query CiphertextBlob
#output echo "output" | base64 -d file.txt
#decrypt via kms .
# aws kms decrypt --ciphertext-blob fileb://file.txt --query Plaintext --output text | base64 -d
@neilkuan
neilkuan / express-quick-start.md
Last active February 15, 2021 02:54
express-quick-start README.md

Create Dir express-quick-start

$ mkdir express-quick-start

$ cd express-quick-start

# init project name foo
$ npx express-generator@4 foo
---
npx: 10 安裝成功,花費 2.298 秒
@neilkuan
neilkuan / install-docker.md
Last active February 10, 2021 23:30 — forked from npearce/install-docker.md
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
# get daemonset image name.
$ kubectl get ds ${DS_NAME} -o json -n kube-system | jq -r .spec.template.spec.containers[].image | sort -u
# get specify pod image name.
$ kubectl get pod -n kube-system | grep ${Pod_Name} | awk '{print $1}' | while read x; do kubectl get pod $x -o json -n kube-system | jq -r .spec.containers[].image; done
# force delete pod
$ kubectl delete pods ${Pod_Name} --grace-period=0 --force
# get all namespace pod image name
@neilkuan
neilkuan / demo-terraform-cloud
Created December 22, 2020 09:58
ORG_NAME_ON_TERRAFORM_CLOUD
terraform {
backend "remote" {
organization = "ORG_NAME_ON_TERRAFORM_CLOUD"
workspaces {
name = "WORKSPACES_NAME_ON_TERRAFORM_CLPUD"
}
}
}
provider "aws" {
cd ~/
sudo yum install ruby -y
sudo amazon-linux-extras install epel -y > /dev/null 2>&1
sudo yum install figlet -y
echo "ruby version"
ruby --version
if [ -f ~/master.zip ]
then
echo "lolcat master.zip already download"