diff --git a/knowledge base/cloud computing/README.placeholder b/knowledge base/cloud computing/README.placeholder index e6a4f97..fe5a6b2 100644 --- a/knowledge base/cloud computing/README.placeholder +++ b/knowledge base/cloud computing/README.placeholder @@ -1,2 +1,3 @@ https://azure.microsoft.com/en-us/resources/cloud-computing-dictionary/what-is-cloud-computing https://cnoe.io/ +https://www.youtube.com/watch?v=xfkqNLzQCX8 diff --git a/snippets/aws/certificates.fish b/snippets/aws/certificates.fish new file mode 100644 index 0000000..6908960 --- /dev/null +++ b/snippets/aws/certificates.fish @@ -0,0 +1,4 @@ +#!/usr/bin/env fish + +# Get certificates +aws acm get-certificate --certificate-arn 'arn:aws:acm:eu-west-1:012345678901:certificate/abcdef01-2345-6789-abcd-ef0123456789' diff --git a/snippets/aws/cli.fish b/snippets/aws/cli.fish new file mode 100644 index 0000000..cd155f9 --- /dev/null +++ b/snippets/aws/cli.fish @@ -0,0 +1,21 @@ +#!/usr/bin/env fish + +# List configured profiles +aws configure list-profiles + +# Configure new profiles +aws configure --profile 'engineer' + + +# Assume roles +aws sts assume-role --role-arn 'arn:aws:iam::012345678901:role/ServiceRole' --role-session-name 'me-as-serviceRole' +aws --profile 'eng' sts assume-role --role-arn 'arn:aws:iam::012345678901:role/ServiceRole' --role-session-name 'eng-as-serviceRole' + + +# Check the credentials are fine +aws sts get-caller-identity +AWS_PROFILE='engineer' aws sts get-caller-identity + + +# Run as Docker container +docker run --rm -ti -v "$HOME/.aws:/root/.aws:ro" 'amazon/aws-cli:2.17.16' autoscaling describe-auto-scaling-groups diff --git a/snippets/aws/deployments.fish b/snippets/aws/deployments.fish new file mode 100644 index 0000000..e285cde --- /dev/null +++ b/snippets/aws/deployments.fish @@ -0,0 +1,13 @@ +#!/usr/bin/env fish + +aws deploy list-applications +aws deploy list-deployment-groups --application-name 'Evidently' +aws deploy get-deployment-group --application-name 'Evidently' --deployment-group-name 'production' --output 'json' | pbcopy + +diff -y -W 200 \ +(aws deploy get-deployment-group --application-name 'Evidently' --deployment-group-name 'staging' --output json | psub) \ +(aws deploy get-deployment-group --application-name 'Evidently' --deployment-group-name 'production' --output 'json' | psub) + +aws deploy create-deployment --application-name 'Evidently' --deployment-group-name 'staging' \ + --description 'This is Evidently a deployment (☞゚∀゚)☞' \ + --s3-location 'bundleType=zip,bucket=deployments-bucket,key=evidently-master-staging.zip' diff --git a/snippets/aws/functions.fish b/snippets/aws/functions.fish index 3014e56..d2f14b2 100644 --- a/snippets/aws/functions.fish +++ b/snippets/aws/functions.fish @@ -2,6 +2,7 @@ alias aws-caller-info 'aws sts get-caller-identity' alias aws-ssm 'aws ssm start-session --target' +alias aws-whoami 'aws-caller-info' function aws-assume-role-by-name set current_caller (aws-caller-info --output json | jq -r '.UserId' -) diff --git a/snippets/aws/commands.fish b/snippets/aws/other commands.fish similarity index 89% rename from snippets/aws/commands.fish rename to snippets/aws/other commands.fish index 46404fb..db015a7 100644 --- a/snippets/aws/commands.fish +++ b/snippets/aws/other commands.fish @@ -1,31 +1,5 @@ #!/usr/bin/env fish -### -# CLI config -# ------------------ -### - -aws configure list-profiles -aws configure --profile 'engineer' - -# Assume roles -aws sts assume-role --role-arn 'arn:aws:iam::012345678901:role/ServiceRole' --role-session-name 'me-as-serviceRole' -aws --profile 'eng' sts assume-role --role-arn 'arn:aws:iam::012345678901:role/ServiceRole' --role-session-name 'eng-as-serviceRole' - -# Check the credentials are fine -aws sts get-caller-identity -AWS_PROFILE='engineer' aws sts get-caller-identity - -docker run --rm -ti -v "$HOME/.aws:/root/.aws:ro" 'amazon/aws-cli:2.17.16' autoscaling describe-auto-scaling-groups - - -### -# ACM -# ------------------ -### - -aws acm get-certificate --certificate-arn 'arn:aws:acm:eu-west-1:012345678901:certificate/abcdef01-2345-6789-abcd-ef0123456789' - ### # Autoscaling Groups @@ -41,24 +15,6 @@ aws autoscaling cancel-instance-refresh --auto-scaling-group-name 'ProductionSer aws autoscaling rollback-instance-refresh --auto-scaling-group-name 'ProductionServers' -### -# CodeDeploy -# ------------------ -### - -aws deploy list-applications -aws deploy list-deployment-groups --application-name 'Evidently' -aws deploy get-deployment-group --application-name 'Evidently' --deployment-group-name 'production' --output 'json' | pbcopy - -diff -y -W 200 \ -(aws deploy get-deployment-group --application-name 'Evidently' --deployment-group-name 'staging' --output json | psub) \ -(aws deploy get-deployment-group --application-name 'Evidently' --deployment-group-name 'production' --output 'json' | psub) - -aws deploy create-deployment --application-name 'Evidently' --deployment-group-name 'staging' \ - --description 'This is Evidently a deployment (☞゚∀゚)☞' \ - --s3-location 'bundleType=zip,bucket=deployments-bucket,key=evidently-master-staging.zip' - - ### # EC2 # ------------------ @@ -80,7 +36,8 @@ aws ec2 describe-images --output 'yaml' \ aws iam list-instance-profiles | grep -i 'ssm' # Check instances are available for use with SSM -aws ssm get-connection-status --query "Status=='connected'" --output 'text' --target "i-0915612ff82914822" +aws ssm get-connection-status --query "Status=='connected'" --output 'text' --target 'i-0915612ff82914822' +aws ssm describe-instance-associations-status --instance-id 'i-0f8b61c78622caed2' # From the instance sudo ssm-cli get-diagnostics --output 'table' @@ -90,6 +47,8 @@ instance_id='i-08fc83ad07487d72f' \ && aws ssm start-session --target "$instance_id" \ || (echo "instance ${instance_id} not available" >&2 && false) +aws ssm describe-instance-associations-status --instance-id 'i-08fc83ad07487d72f' + # Send commands aws ssm send-command --instance-ids 'i-08fc83ad07487d72f' --document-name 'AWS-RunShellScript' --parameters "commands='echo hallo'" aws ssm wait command-executed --command-id 'e5f7ca0e-4d74-4316-84be-9ccaf3ae1f70' --instance-id 'i-08fc83ad07487d72f'