AWS QUERY
1. Add CName
aws route53 list-hosted-zones-by-name
extract all hostname and ip
aws route53 list-resource-record-sets --hosted-zone-id Z09511272L9RSIIGXU10I | jq -r '.ResourceRecordSets[]? | select(has("ResourceRecords")) | "\(.Name) \(.ResourceRecords[].Value)"'
aws route53 list-resource-record-sets --hosted-zone-id hostzone-id | jq -r '.ResourceRecordSets[] | "\(.Name) \(.ResourceRecords[].Value)"
aws route53 change-resource-record-sets --hosted-zone-id xxxxx --change-batch file://change-config.json
aws ec2 describe-images --image-ids ami-04dd25bed545fcfb7 --query 'Images[*].{ID:ImageId, CreationDate:CreationDate}' --output table
Copy hostname info to aws_utilities/data/dns.txt
run aws.create_cname_record('aws_utilities/data/dns.txt','CLs Request : Cassandra')
cat change-config.json
{
"Comment": "Add CNAME for hostname",
"Changes": [
{
"Action": "CREATE",
"ResourceRecordSet": {
"Name": "a.abc.com.",
"Type": "A",
"TTL": 60,
"ResourceRecords": [{"Value": "5.5.5.5"}]
}
},
{
"Action": "CREATE",
"ResourceRecordSet": {
"Name": "b.abc.com",
"Type": "A",
"TTL": 60,
"ResourceRecords": [{"Value": "10.10.10.10"}]
}
}
]
}
finally run aws route53 change-resource-record-sets --hosted-zone-id Z0166539213Z70FYI18TX --change-batch file://change-config.json
2. AWS Queries
Check EC2
aws ec2 describe-volumes --filters Name=tag:ebs-host,Values='postgres*','oracle*' \
--query "Volumes[?State=='in-use'].{ID:VolumeId,Hostname:Tags[?Key=='ebs-host']|[0].Value,State:State,Size:Size,VolumeType:VolumeType,IOPS:Iops, InstanceType: InstanceType } | sort_by([], &to_string(Hostname))" \
--output table
Check Clouformation
aws cloudformation describe-stacks \
--query "sort_by(Stacks, &StackName)[?contains(StackName,'oracle')||contains(StackName,'postgresql')||contains(StackName,'mysql')]|[?Tags[?Key=='stack-prefix']|[0].Value=='default'].\
{StackName:StackName,StackPrefix:Tags[?Key=='stack-prefix']|[0].Value,LastUpdatedTime:LastUpdatedTime,CreatedTime:CreationTime}" \
--output table
Query stack for all datastore
aws cloudformation describe-stacks \
--query "sort_by(Stacks, &StackName)[?contains(StackName,'oracle')||contains(StackName,'postgresql')||contains(StackName,'mysql')||contains(StackName,'mssql')||contains(StackName,'es')]|[?Tags[?Key=='stack-prefix']|[0].Value=='default'].\
{StackName:StackName,StackPrefix:Tags[?Key=='stack-prefix']|[0].Value,LastUpdatedTime:LastUpdatedTime,CreatedTime:CreationTime}" \
--output table
Check EBS volume
aws ec2 describe-volumes --filters Name=tag:ebs-host,Values='mysql*','postgresql*' \
--query "Volumes[?State=='in-use'].{ID:VolumeId,Hostname:Tags[?Key=='ebs-host']|[0].Value,State:State,Size:Size,VolumeType:VolumeType,IOPS:Iops, InstanceType: InstanceType } | sort_by([], &to_string(Hostname))" \
--output table
​
3. Query Execution time
​
Check AWS Stack execution time
​
start_time=$(aws cloudformation describe-stack-events --stack-name sam-reflection-check-db-lag-lambda-pbcdv01aws | jq -r '.StackEvents[] | select(.ResourceType=="AWS::CloudFormation::Stack" and .ResourceStatus=="CREATE_IN_PROGRESS") | .Timestamp')
end_time=$(aws cloudformation describe-stack-events --stack-name sam-reflection-check-db-lag-lambda-pbcdv01aws | jq -r '.StackEvents[] | select(.ResourceType=="AWS::CloudFormation::Stack" and .ResourceStatus=="CREATE_COMPLETE") | .Timestamp')
echo "Start Time: $start_time"
echo "End Time: $end_time"
​
4. Get all ES domain info from CLI
​
aws es list-domain-names --query 'DomainNames[*].DomainName' --output text | xargs -n 1 aws es describe-elasticsearch-domain --domain-name
​