AWS : jq
bogotobogo.com site search:
In this post, we'll see some of the jq
samples with AWS.
jq samples : #1
$ aws cloudformation describe-stacks --stack-name "$STACK_NAME" { "Stacks": [ { "StackId": "arn:aws:cloudformation:us-east-1:526262051452:stack/eksctl-eks-fargate-alb-bogo-cluster/fee05810-b8bc-11eb-930e-12878b97cc21", "StackName": "eksctl-eks-fargate-alb-bogo-cluster", "Description": "EKS cluster (dedicated VPC: true, dedicated IAM: true) [created and managed by eksctl]", "CreationTime": "2021-05-19T16:12:23.699000+00:00", "RollbackConfiguration": {}, "StackStatus": "CREATE_COMPLETE", "DisableRollback": false, "NotificationARNs": [], "Capabilities": [ "CAPABILITY_IAM" ], "Outputs": [ { "OutputKey": "SubnetsPrivate", "OutputValue": "subnet-0de433a237d674ccd,subnet-0a5bc2ccb56833993", "ExportName": "eksctl-eks-fargate-alb-bogo-cluster::SubnetsPrivate" }, { "OutputKey": "SubnetsPublic", "OutputValue": "subnet-0076d3dcec303c8f1,subnet-0bf2f1d8a7677eeab", "ExportName": "eksctl-eks-fargate-alb-bogo-cluster::SubnetsPublic" }, { "OutputKey": "ServiceRoleARN", "OutputValue": "arn:aws:iam::526262051452:role/eksctl-eks-fargate-alb-bogo-cluster-ServiceRole-DQFROGF2NVMS", "ExportName": "eksctl-eks-fargate-alb-bogo-cluster::ServiceRoleARN" }, { "OutputKey": "VPC", "OutputValue": "vpc-0cc69def2e81ac1c9", "ExportName": "eksctl-eks-fargate-alb-bogo-cluster::VPC" }, { "OutputKey": "ClusterStackName", "OutputValue": "eksctl-eks-fargate-alb-bogo-cluster" }, { "OutputKey": "CertificateAuthorityData", "OutputValue": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeE1EVXhPVEUyTVRrMU0xb1hEVE14TURVeE56RTJNVGsxTTF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xdGhES3V0SUhFSAo1aDdSdXlFMGpWL0JZZXlPNzQvbUQwMWI1VEduRHV0aVVjeHhzeUFHakltWXFUb0FJeHFpOWdJY0pXMD0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=" }, { "OutputKey": "SecurityGroup", "OutputValue": "sg-00d64c4d55565b5e3", "ExportName": "eksctl-eks-fargate-alb-bogo-cluster::SecurityGroup" }, { "OutputKey": "FeatureNATMode", "OutputValue": "Single" }, { "OutputKey": "Endpoint", "OutputValue": "https://62CA4123A8495432655F46B2EFE83DC2.gr7.us-east-1.eks.amazonaws.com", "ExportName": "eksctl-eks-fargate-alb-bogo-cluster::Endpoint" }, { "OutputKey": "SharedNodeSecurityGroup", "OutputValue": "sg-0dc51b1fb6c3c5ca9", "ExportName": "eksctl-eks-fargate-alb-bogo-cluster::SharedNodeSecurityGroup" }, { "OutputKey": "ClusterSecurityGroupId", "OutputValue": "sg-0311b879a633cdcb4", "ExportName": "eksctl-eks-fargate-alb-bogo-cluster::ClusterSecurityGroupId" }, { "OutputKey": "ARN", "OutputValue": "arn:aws:eks:us-east-1:526262051452:cluster/eks-fargate-alb-bogo", "ExportName": "eksctl-eks-fargate-alb-bogo-cluster::ARN" }, { "OutputKey": "FargatePodExecutionRoleARN", "OutputValue": "arn:aws:iam::526262051452:role/eksctl-eks-fargate-alb-bog-FargatePodExecutionRole-SNQMWZR33SM5", "ExportName": "eksctl-eks-fargate-alb-bogo-cluster::FargatePodExecutionRoleARN" } ], "Tags": [ { "Key": "alpha.eksctl.io/cluster-name", "Value": "eks-fargate-alb-bogo" }, { "Key": "eksctl.cluster.k8s.io/v1alpha1/cluster-name", "Value": "eks-fargate-alb-bogo" }, { "Key": "alpha.eksctl.io/eksctl-version", "Value": "0.44.0" } ], "EnableTerminationProtection": false, "DriftInformation": { "StackDriftStatus": "NOT_CHECKED" } } ] } $ aws cloudformation describe-stacks --stack-name "$STACK_NAME" | jq -r '[.Stacks[0].Outputs[] | {key: .OutputKey, value: .OutputValue}] | from_entries' { "SubnetsPrivate": "subnet-0de433a237d674ccd,subnet-0a5bc2ccb56833993", "SubnetsPublic": "subnet-0076d3dcec303c8f1,subnet-0bf2f1d8a7677eeab", "ServiceRoleARN": "arn:aws:iam::526262051452:role/eksctl-eks-fargate-alb-bogo-cluster-ServiceRole-DQFROGF2NVMS", "VPC": "vpc-0cc69def2e81ac1c9", "ClusterStackName": "eksctl-eks-fargate-alb-bogo-cluster", "CertificateAuthorityData": "LS0tL6RUOVZOMmVvMUN0JMNWtLQo=", "SecurityGroup": "sg-00d64c4d55565b5e3", "FeatureNATMode": "Single", "Endpoint": "https://62CA4123A8495432655F46B2EFE83DC2.gr7.us-east-1.eks.amazonaws.com", "SharedNodeSecurityGroup": "sg-0dc51b1fb6c3c5ca9", "ClusterSecurityGroupId": "sg-0311b879a633cdcb4", "ARN": "arn:aws:eks:us-east-1:526262051452:cluster/eks-fargate-alb-bogo", "FargatePodExecutionRoleARN": "arn:aws:iam::526262051452:role/eksctl-eks-fargate-alb-bog-FargatePodExecutionRole-SNQMWZR33SM5" } $ VPC_ID=$(aws cloudformation describe-stacks --stack-name "$STACK_NAME" | jq -r '[.Stacks[0].Outputs[] | {key: .OutputKey, value: .OutputValue}] | from_entries' | jq -r '.VPC') $ echo $VPC_ID vpc-0cc69def2e81ac1c9
jq samples : #2
$ aws sts get-caller-identity { "UserId": "AIDAJIX6NM5BAIKEDHN3W", "Account": "526262051452", "Arn": "arn:aws:iam::526262051452:user/K" } $ AWS_ACCOUNT_ID=$(aws sts get-caller-identity | jq -r '.Account') $ echo $AWS_ACCOUNT_ID 526262051452
jq samples : #3
$ kubectl get ingress nginx-ingress -o json { "apiVersion": "extensions/v1beta1", "kind": "Ingress", "metadata": { "annotations": { "alb.ingress.kubernetes.io/scheme": "internet-facing", "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"extensions/v1beta1\",\"kind\":\"Ingress\",\"metadata\":{\"annotations\":{\"alb.ingress.kubernetes.io/scheme\":\"internet-facing\",\"kubernetes.io/ingress.class\":\"alb\"},\"labels\":{\"app\":\"nginx-ingress\"},\"name\":\"nginx-ingress\",\"namespace\":\"default\"},\"spec\":{\"rules\":[{\"http\":{\"paths\":[{\"backend\":{\"serviceName\":\"nginx-service\",\"servicePort\":80},\"path\":\"/*\"}]}}]}}\n", "kubernetes.io/ingress.class": "alb" }, "creationTimestamp": "2021-05-19T17:21:09Z", "generation": 1, "labels": { "app": "nginx-ingress" }, "managedFields": [ { "apiVersion": "extensions/v1beta1", "fieldsType": "FieldsV1", "fieldsV1": { "f:metadata": { "f:annotations": { ".": {}, "f:alb.ingress.kubernetes.io/scheme": {}, "f:kubectl.kubernetes.io/last-applied-configuration": {}, "f:kubernetes.io/ingress.class": {} }, "f:labels": { ".": {}, "f:app": {} } }, "f:spec": { "f:rules": {} } }, "manager": "kubectl", "operation": "Update", "time": "2021-05-19T17:21:09Z" }, { "apiVersion": "extensions/v1beta1", "fieldsType": "FieldsV1", "fieldsV1": { "f:status": { "f:loadBalancer": { "f:ingress": {} } } }, "manager": "server", "operation": "Update", "time": "2021-05-19T17:21:15Z" } ], "name": "nginx-ingress", "namespace": "default", "resourceVersion": "11323", "selfLink": "/apis/extensions/v1beta1/namespaces/default/ingresses/nginx-ingress", "uid": "a521d23d-e971-4523-986e-d61669de47d7" }, "spec": { "rules": [ { "http": { "paths": [ { "backend": { "serviceName": "nginx-service", "servicePort": 80 }, "path": "/*", "pathType": "ImplementationSpecific" } ] } } ] }, "status": { "loadBalancer": { "ingress": [ { "hostname": "8c14e961-default-nginxingr-29e9-1292497776.us-east-1.elb.amazonaws.com" } ] } } } $ kubectl get ingress nginx-ingress -o json | jq -r '.status.loadBalancer.ingress[0].hostname' 8c14e961-default-nginxingr-29e9-1292497776.us-east-1.elb.amazonaws.com $ LOADBALANCER_PREFIX=$(kubectl get ingress nginx-ingress -o json | jq -r '.status.loadBalancer.ingress[0].hostname' | cut -d- -f1) $ echo $LOADBALANCER_PREFIX 8c14e961
jq samples : #4
$ aws elbv2 describe-target-groups | jq -r '.TargetGroups[].TargetGroupArn' arn:aws:elasticloadbalancing:us-east-1:526262051452:targetgroup/8c14e961-f8c4797641154edfb62/c1f40081fd607c40 arn:aws:elasticloadbalancing:us-east-1:526262051452:targetgroup/myTG/ffa4755fabc5ea1c $ TARGETGROUP_ARN=$(aws elbv2 describe-target-groups | jq -r '.TargetGroups[].TargetGroupArn' | grep $LOADBALANCER_PREFIX) $ echo TARGETGROUP_ARN arn:aws:elasticloadbalancing:us-east-1:526262051452:targetgroup/8c14e961-f8c4797641154edfb62/c1f40081fd607c40
jq samples : #5
$ aws elbv2 describe-target-health --target-group-arn $TARGETGROUP_ARN { "TargetHealthDescriptions": [ { "Target": { "Id": "192.168.79.53", "Port": 80, "AvailabilityZone": "us-east-1c" }, "HealthCheckPort": "80", "TargetHealth": { "State": "healthy" } }, { "Target": { "Id": "192.168.127.30", "Port": 80, "AvailabilityZone": "us-east-1f" }, "HealthCheckPort": "80", "TargetHealth": { "State": "healthy" } }, { "Target": { "Id": "192.168.101.8", "Port": 80, "AvailabilityZone": "us-east-1f" }, "HealthCheckPort": "80", "TargetHealth": { "State": "healthy" } } ] } $ aws elbv2 describe-target-health --target-group-arn $TARGETGROUP_ARN | jq -r '.TargetHealthDescriptions[].TargetHealth.State' healthy healthy healthy
AWS (Amazon Web Services)
- AWS : EKS (Elastic Container Service for Kubernetes)
- AWS : Creating a snapshot (cloning an image)
- AWS : Attaching Amazon EBS volume to an instance
- AWS : Adding swap space to an attached volume via mkswap and swapon
- AWS : Creating an EC2 instance and attaching Amazon EBS volume to the instance using Python boto module with User data
- AWS : Creating an instance to a new region by copying an AMI
- AWS : S3 (Simple Storage Service) 1
- AWS : S3 (Simple Storage Service) 2 - Creating and Deleting a Bucket
- AWS : S3 (Simple Storage Service) 3 - Bucket Versioning
- AWS : S3 (Simple Storage Service) 4 - Uploading a large file
- AWS : S3 (Simple Storage Service) 5 - Uploading folders/files recursively
- AWS : S3 (Simple Storage Service) 6 - Bucket Policy for File/Folder View/Download
- AWS : S3 (Simple Storage Service) 7 - How to Copy or Move Objects from one region to another
- AWS : S3 (Simple Storage Service) 8 - Archiving S3 Data to Glacier
- AWS : Creating a CloudFront distribution with an Amazon S3 origin
- AWS : Creating VPC with CloudFormation
- AWS : WAF (Web Application Firewall) with preconfigured CloudFormation template and Web ACL for CloudFront distribution
- AWS : CloudWatch & Logs with Lambda Function / S3
- AWS : Lambda Serverless Computing with EC2, CloudWatch Alarm, SNS
- AWS : Lambda and SNS - cross account
- AWS : CLI (Command Line Interface)
- AWS : CLI (ECS with ALB & autoscaling)
- AWS : ECS with cloudformation and json task definition
- AWS Application Load Balancer (ALB) and ECS with Flask app
- AWS : Load Balancing with HAProxy (High Availability Proxy)
- AWS : VirtualBox on EC2
- AWS : NTP setup on EC2
- AWS: jq with AWS
- AWS & OpenSSL : Creating / Installing a Server SSL Certificate
- AWS : OpenVPN Access Server 2 Install
- AWS : VPC (Virtual Private Cloud) 1 - netmask, subnets, default gateway, and CIDR
- AWS : VPC (Virtual Private Cloud) 2 - VPC Wizard
- AWS : VPC (Virtual Private Cloud) 3 - VPC Wizard with NAT
- DevOps / Sys Admin Q & A (VI) - AWS VPC setup (public/private subnets with NAT)
- AWS - OpenVPN Protocols : PPTP, L2TP/IPsec, and OpenVPN
- AWS : Autoscaling group (ASG)
- AWS : Setting up Autoscaling Alarms and Notifications via CLI and Cloudformation
- AWS : Adding a SSH User Account on Linux Instance
- AWS : Windows Servers - Remote Desktop Connections using RDP
- AWS : Scheduled stopping and starting an instance - python & cron
- AWS : Detecting stopped instance and sending an alert email using Mandrill smtp
- AWS : Elastic Beanstalk with NodeJS
- AWS : Elastic Beanstalk Inplace/Rolling Blue/Green Deploy
- AWS : Identity and Access Management (IAM) Roles for Amazon EC2
- AWS : Identity and Access Management (IAM) Policies, sts AssumeRole, and delegate access across AWS accounts
- AWS : Identity and Access Management (IAM) sts assume role via aws cli2
- AWS : Creating IAM Roles and associating them with EC2 Instances in CloudFormation
- AWS Identity and Access Management (IAM) Roles, SSO(Single Sign On), SAML(Security Assertion Markup Language), IdP(identity provider), STS(Security Token Service), and ADFS(Active Directory Federation Services)
- AWS : Amazon Route 53
- AWS : Amazon Route 53 - DNS (Domain Name Server) setup
- AWS : Amazon Route 53 - subdomain setup and virtual host on Nginx
- AWS Amazon Route 53 : Private Hosted Zone
- AWS : SNS (Simple Notification Service) example with ELB and CloudWatch
- AWS : Lambda with AWS CloudTrail
- AWS : SQS (Simple Queue Service) with NodeJS and AWS SDK
- AWS : Redshift data warehouse
- AWS : CloudFormation
- AWS : CloudFormation Bootstrap UserData/Metadata
- AWS : CloudFormation - Creating an ASG with rolling update
- AWS : Cloudformation Cross-stack reference
- AWS : OpsWorks
- AWS : Network Load Balancer (NLB) with Autoscaling group (ASG)
- AWS CodeDeploy : Deploy an Application from GitHub
- AWS EC2 Container Service (ECS)
- AWS EC2 Container Service (ECS) II
- AWS Hello World Lambda Function
- AWS Lambda Function Q & A
- AWS Node.js Lambda Function & API Gateway
- AWS API Gateway endpoint invoking Lambda function
- AWS API Gateway invoking Lambda function with Terraform
- AWS API Gateway invoking Lambda function with Terraform - Lambda Container
- Amazon Kinesis Streams
- AWS: Kinesis Data Firehose with Lambda and ElasticSearch
- Amazon DynamoDB
- Amazon DynamoDB with Lambda and CloudWatch
- Loading DynamoDB stream to AWS Elasticsearch service with Lambda
- Amazon ML (Machine Learning)
- Simple Systems Manager (SSM)
- AWS : RDS Connecting to a DB Instance Running the SQL Server Database Engine
- AWS : RDS Importing and Exporting SQL Server Data
- AWS : RDS PostgreSQL & pgAdmin III
- AWS : RDS PostgreSQL 2 - Creating/Deleting a Table
- AWS : MySQL Replication : Master-slave
- AWS : MySQL backup & restore
- AWS RDS : Cross-Region Read Replicas for MySQL and Snapshots for PostgreSQL
- AWS : Restoring Postgres on EC2 instance from S3 backup
- AWS : Q & A
- AWS : Security
- AWS : Security groups vs. network ACLs
- AWS : Scaling-Up
- AWS : Networking
- AWS : Single Sign-on (SSO) with Okta
- AWS : JIT (Just-in-Time) with Okta
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization