AWS CLI: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
 
(10 intermediate revisions by the same user not shown)
Line 5: Line 5:
sudo    ${HOME}/Downloads/aws/install
sudo    ${HOME}/Downloads/aws/install
rm -rf  ${HOME}/Downloads/aws
rm -rf  ${HOME}/Downloads/aws
</syntaxhighlight>
==AWS » Profile==
<syntaxhighlight lang="bash">
export AWS_PROFILE=chorke.academia
export AWS_PROFILE=chorke
aws ec2 describe-availability-zones
aws sts get-caller-identity
aws configure list
aws s3 ls
</syntaxhighlight>
==AWS » Route 53==
<syntaxhighlight lang="bash">
aws route53 list-hosted-zones --output=json
aws route53 list-resource-record-sets --hosted-zone-id=Z2U6EL1ZO4QJ1T --output=json
</syntaxhighlight>
----
<syntaxhighlight lang="bash">
export AWS_PROFILE=chorke
aws route53 list-hosted-zones --output=json > aws-chorke-zones.json
ZONE_NAME=chorke.org
HOSTED_ZONE_ID=$(cat aws-chorke-zones.json | jq -r ".HostedZones[] | select(.Name == \"${ZONE_NAME}.\") | .Id" | cut -d'/' -f3)
aws route53 list-resource-record-sets --hosted-zone-id=${HOSTED_ZONE_ID} --output=json > aws-chorke-zone-${ZONE_NAME}.json
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|select(.Type=="A")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|select(.Type=="MX")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|select(.Type=="NS")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|select(.Type=="SOA")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|select(.Type=="TXT")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|select(.Type=="CNAME")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="A")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="MX")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="NS")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="SOA")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="TXT")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="CNAME")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|"\(.Name) \t\(.TTL) \t\(.Type) \t\(.AliasTarget?.DNSName)\n"'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|"\(.Name) \t\(.TTL) \t\(.Type) \t\(.ResourceRecords[]?.Value)\n"'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="A")|"\(.Name) \t1\tIN\t\(.Type) \t\(.ResourceRecords[0].Value)\n"'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="MX")|"\(.Name) \t1\tIN\t\(.Type) \t\(.ResourceRecords[0].Value)\n"'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="TXT")|"\(.Name) \t1\tIN\t\(.Type) \t\(.ResourceRecords[0].Value)\n"'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="CNAME")|"\(.Name) \t1\tIN\t\(.Type) \t\(.ResourceRecords[0].Value)\n"'
</syntaxhighlight>
</syntaxhighlight>


Line 59: Line 108:
| valign="top" |
| valign="top" |
  aws configure --profile academia
  aws configure --profile academia
  aws configure help
  aws sts get-caller-identity
  aws configure list
  aws configure list
  aws configure
  aws configure

Latest revision as of 02:55, 22 November 2024

wget -cq https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -P ${HOME}/Downloads
unzip -q ${HOME}/Downloads/awscli-exe-linux-x86_64.zip -d ${HOME}/Downloads/
rm -rf   ${HOME}/Downloads/awscli-exe-linux-x86_64.zip
sudo     ${HOME}/Downloads/aws/install
rm -rf   ${HOME}/Downloads/aws

AWS » Profile

export AWS_PROFILE=chorke.academia
export AWS_PROFILE=chorke

aws ec2 describe-availability-zones
aws sts get-caller-identity
aws configure list
aws s3 ls

AWS » Route 53

aws route53 list-hosted-zones --output=json
aws route53 list-resource-record-sets --hosted-zone-id=Z2U6EL1ZO4QJ1T --output=json

export AWS_PROFILE=chorke
aws route53 list-hosted-zones --output=json > aws-chorke-zones.json

ZONE_NAME=chorke.org
HOSTED_ZONE_ID=$(cat aws-chorke-zones.json | jq -r ".HostedZones[] | select(.Name == \"${ZONE_NAME}.\") | .Id" | cut -d'/' -f3)
aws route53 list-resource-record-sets --hosted-zone-id=${HOSTED_ZONE_ID} --output=json > aws-chorke-zone-${ZONE_NAME}.json


cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|select(.Type=="A")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|select(.Type=="MX")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|select(.Type=="NS")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|select(.Type=="SOA")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|select(.Type=="TXT")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|select(.Type=="CNAME")'

cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="A")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="MX")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="NS")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="SOA")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="TXT")'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="CNAME")'

cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|"\(.Name) \t\(.TTL) \t\(.Type) \t\(.AliasTarget?.DNSName)\n"'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets[]|"\(.Name) \t\(.TTL) \t\(.Type) \t\(.ResourceRecords[]?.Value)\n"'

cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="A")|"\(.Name) \t1\tIN\t\(.Type) \t\(.ResourceRecords[0].Value)\n"'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="MX")|"\(.Name) \t1\tIN\t\(.Type) \t\(.ResourceRecords[0].Value)\n"'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="TXT")|"\(.Name) \t1\tIN\t\(.Type) \t\(.ResourceRecords[0].Value)\n"'
cat aws-chorke-zone-${ZONE_NAME}.json | jq -jr '.ResourceRecordSets|sort_by(.Name)[]|select(.Type=="CNAME")|"\(.Name) \t1\tIN\t\(.Type) \t\(.ResourceRecords[0].Value)\n"'

Playground

cat << INI | tee -a ${HOME}/.aws/config >/dev/null
[default]
region = ap-southeast-1
output = table

INI
cat << INI | tee -a ${HOME}/.aws/credentials >/dev/null
[academia]
aws_access_key_id = AKIBVWTF7RISAULV8Q6Q
aws_secret_access_key = w2JVkDIE9zRTIP/S4m7Mm4cWKlFEYlzg1iGzfCnj

INI
cat << INI | tee -a ${HOME}/.aws/config >/dev/null
[profile academia]
region = ap-southeast-1
output = json

INI

export AWS_DEFAULT_PROFILE=academia
export AWS_PROFILE=academia
aws ec2 describe-vpcs
aws s3 ls
aws kms delete-alias --alias-name \
 arn:aws:kms:ap-southeast-1:235216370500:alias/eks/sdlc_cluster
cat ~/.aws/credentials
cat ~/.aws/config
aws configure --profile academia
aws sts get-caller-identity
aws configure list
aws configure

kubectl config set-context  minikube --cluster=minikue
kubectl config set-context  minikube
kubectl config get-contexts
kubectl config get-clusters
kubectl config view

References