Skip to content

Instantly share code, notes, and snippets.

View neilkuan's full-sized avatar
🎯
Focusing

Neil Kuan neilkuan

🎯
Focusing
View GitHub Profile
@neilkuan
neilkuan / cdk_stack.py
Created April 4, 2020 08:13
cdk_stack.py
##from aws_cdk import core
#import modlue you needed
import os.path as path
import sys
from aws_cdk import (
core,
aws_ec2 as ec2,
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "CrossAccountPull",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::1333333333:root"
},
# need awscli >= 1.16.x , docker
# aws ecr get-login --registry-ids < ecr-account-id > --region < region-you-want > --no-include-email
#way 1.
# Get docker registry token from A account ECR
[ec2-user@192-168-0-99 ~ ] aws ecr get-login --registry-ids 1333333333 --region ap-northeast-1 --no-include-email
#--output
docker login -u AWS -p eyJwYXlsb2FkIjoi....NUZCeTkydVU2b2R9 https://1333333333.dkr.ecr.us-east-1.amazonaws.com
# Copy output for Login A account ECR
$ curl -LO https://eksworkshop.com/beginner/110_irsa/deploy.files/iam-pod.yaml
--- inside
apiVersion: apps/v1
kind: Deployment
metadata:
name: eks-iam-test
spec:
replicas: 1
selector:
matchLabels:
exports.handler = (event, context, callback) => {
// Extract the request from the CloudFront event that is sent to Lambda@Edge
var request = event.Records[0].cf.request;
var newuri = ''
// Extract the URI from the request
var olduri = request.uri;
if (olduri == '/'){
newuri = olduri+ 'index.html';
}else{
version: "3.7"
services:
nexus:
image: "sonatype/nexus3:3.19.1"
container_name: "nexus"
restart: always
ports:
- "8081:8081"
- "5000:5000"
volumes:
#!/bin/bash
TMPFILE=/tmp/u53tempfile
TMPFILE_URI="file://$TMPFILE"
AWS=/usr/local/bin/aws
function try {
eval $*
if [ $? -ne 0 ]; then
echo "Error while evaluating \"$*\", exiting..."
@neilkuan
neilkuan / init-super-user.sh
Created September 29, 2020 02:28
Use AWS CLI to create Super User , so fast !!!
#!/bin/bash
set pipefail
if [ $# != 2 ]
then
echo "Please give username and password \n ./init-super-user.sh tempuser 2wsx#EDCv ..."
exit 1
fi
USER_NAME=$1
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: __API_NAME__
namespace: __NAMESPACE__
spec:
maxReplicas: 2
minReplicas: 1
scaleTargetRef:
apiVersion: extensions/v1beta1
#!/bin/bash
export AWS_DEFAULT_REGION=ap-northeast-1
aws logs describe-log-streams --log-group-name fluentbit-cloudwatch --query 'logStreams[*].logStreamName' --output table \
| awk '{print $2}' | grep ^$2 \
| while read x; do echo "deleting $x" ; aws logs delete-log-stream --log-group-name $1 --log-stream-name $x; done