DEV Community

Cover image for Lazy Add IAM Access Key
πŸš€ Vu Dao πŸš€
πŸš€ Vu Dao πŸš€

Posted on β€’ Edited on

2 2

Lazy Add IAM Access Key

Use expect programming language to add you IAM access key by one enter

What’s In This Document

πŸš€ Write the code

add_key.sh

#!/usr/bin/expect

set access_key [lindex $argv 0]
set screte_key [lindex $argv 1]

spawn aws configure

# Add access key
expect "]:"
send "$access_key\r"

# Add secrete key
expect "]:"
send "$screte_key\r"

# Default region
expect "]:"
send "\r"

# Default output format
expect "]:"
send "\r"

interact
Enter fullscreen mode Exit fullscreen mode

πŸš€ Run example

  • First arg is access key
  • Second one is secrete key
⚑ $ ./add_key.sh a1234a b4567b
spawn aws configure
AWS Access Key ID [****************XXXX]: a1234a
AWS Secret Access Key [****************YYYY]: b4567b
Default region name [ap-northeast-2]: 
Default output format [None]: 

⚑ $ aws configure list
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ****************234a shared-credentials-file    
secret_key     ****************567b shared-credentials-file    
    region           ap-northeast-2      config-file    ~/.aws/config
Enter fullscreen mode Exit fullscreen mode

Visit www.cloudopz.co to get more

🌠 Blog · Web · Linkedin · Group · Page · Twitter 🌠

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (2)

Collapse
 
routinggames profile image
Duy Nguy3n β€’

Thanks for sharing

Collapse
 
tuannguyen91vn profile image
Blake (Tuan Nguyen) β€’

Very useful, thank bro!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay