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]);
}
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 | |
| ##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} |
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 | |
| #!/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 |
$ 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
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 | |
| #$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 |
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/
sudo amazon-linux-extras install docker
sudo service docker start
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
| # 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 |
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
| terraform { | |
| backend "remote" { | |
| organization = "ORG_NAME_ON_TERRAFORM_CLOUD" | |
| workspaces { | |
| name = "WORKSPACES_NAME_ON_TERRAFORM_CLPUD" | |
| } | |
| } | |
| } | |
| provider "aws" { |