How to AWS sts assume role in one command - without jq

The issue - what it takes to assume a role To assume an AWS role in the CLI, you will have to do something like this: aws sts assume-role --role-arn arn:aws:iam::123456789123:role/myAwesomeRole --role-session-name test --region eu-central-1 This will give you the following output: { "Credentials": { "AccessKeyId": "someAccessKeyId", "SecretAccessKey": "someSecretAccessKey", "SessionToken": "someSessionToken", "Expiration": "20203-01-02T06:52:13+00:00" }, "AssumedRoleUser": { "AssumedRoleId": "idOfTheAssummedRole", "Arn": "theARNOfTheRoleIWantToAssume" } } But then you will have to manually copy and paste the values of AccessKeyId, SecretAccessKey and SessionToken in a bunch of exports like this:...

June 9, 2023 · 1 min · 168 words · AO

[Solved] Docker Daemon Connection Error: Daemon Running?

If you get the following error when trying to run a Docker container: Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? Then you can resolve it by running the following: systemctl start docker If this doesn’t work because of a root user issue, then you can do the following first: gpasswd -a $USER docker Additional issues? Issue 1 If you have tried the above, and get this error:...

March 4, 2023 · 1 min · 117 words · AO

[Solved] M1 Docker Image Platform Mismatch with Host (ARM64)

If you get the following error when trying to run a Docker container that was built on an M1 mac: M1 docker preview and keycloak 'image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8)' Issue The solution Then you can do simply add the following argument to your docker build command. --platform linux/amd64 Where this goes docker build --platform linux/amd64 -t your_docker_item .

March 3, 2023 · 1 min · 65 words · AO

How to Return a List of All AWS Lambda Function Names in CLI

If you would like to list all AWS Lambda Function Names in your CLI using the AWS CLI, then you can do this: Get a List of all Lambda Functions aws lambda list-functions However, note that this will return a potentially large JSON payload back to your CLI. So what if you only want a list of the function names themselves? You can couple the AWS command above, with the jq command as follows:...

February 24, 2023 · 1 min · 88 words · AO

How to Install AWS SAM CLI on Mac

If you need to install AWS SAM CLI on a Mac, then the easiest option is to use Homebrew with the following commands: brew tap aws/tap brew install aws-sam-cli Now you can validate the installation as follows: sam --version

February 15, 2023 · 1 min · 39 words · AO

How to Empty and Delete an S3 Bucket using the AWS CLI

Option 1 – Using AWS CLI Step 1 export bucketname='your-bucket-here' Step 2 aws s3api delete-objects --bucket $bucketname --delete "$(aws s3api list-object-versions --bucket $bucketname --output=json --query='{Objects: *[].{Key:Key,VersionId:VersionId}}')"; Step 3 aws s3 rb s3://$bucketname Option 2 – Using Python #!/usr/bin/env python BUCKET = 'your-bucket-here' import boto3 s3 = boto3.resource('s3') bucket = s3.Bucket(BUCKET) bucket.object_versions.delete() bucket.delete()

November 9, 2022 · 1 min · 52 words · Andrew

How to Execute a Shell Script in NodeJS

If you need to execute a shell script in NodeJS, then you can use the exec keyword. Syntax: exec(command [, options] [, callback] const shell = require('shelljs') shell.exec("npm --version")

October 25, 2022 · 1 min · 29 words · Andrew

How to Delete all Resources Except One in Terraform

If you need to delete all resources created by Terraform, except for a single, specific one, then you can do the following: Step 1 – Get the current state list terraform state list Step 2 – Remove the exception resource Remove the specific resource that you don’t want Terraform to track anymore. terraform state rm <resource_to_be_removed> Step 3 – Destroy the resources terraform destroy

October 23, 2022 · 1 min · 64 words · Andrew

How to Copy Files between Two Nodes using Ansible

If you need to copy files between two (2) nodes, using Ansible, then you can do the following: This solution uses the synchronize module, specifically using the delegate_to:source-server keywords. - hosts: serverB tasks: - name: Copy Remote-To-Remote (from serverA to serverB) synchronize: src=/copy/from_serverA dest=/copy/to_serverB delegate_to: serverA

October 22, 2022 · 1 min · 46 words · Andrew

How to Delete Files and Folders in a Directory using Ansible

If you need to delete files and folders in a directory using Ansible, then you can do the following: - name: Delete content & entire directory file: state: absent path: /some/directory/path/

October 21, 2022 · 1 min · 31 words · Andrew