Exo / Create New Api Key
Create New Api Key
Create a new API key associated with a specified IAM role using the Exo CLI.
exo iam api-key create <api_key_name> <iam_role_name> exo iam api-key create <api_key_name> <iam_role_name> #!/bin/bash
# Create New Api Key
exo iam api-key create {{api_key_name}} {{iam_role_name}} import subprocess
# Create New Api Key
# Make sure to replace <placeholders> with actual values
def run_command():
cmd = [
"exo",
"iam",
"api-key",
"create",
"<api_key_name>",
"<iam_role_name>"
]
try:
print(f"Executing: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
except FileNotFoundError:
print("Error: exo not found. Please install it first.")
if __name__ == "__main__":
run_command() When To Use
When setting up access for a new application module requiring API integration with specific role privileges.
Pro Tip
Use a strong naming convention for your API key to prevent conflicts and help with management, and ensure that you rotate keys periodically.
Command Builder
Tune the command before you copy it
exo iam api-key create <api_key_name> <iam_role_name> Anatomy of Output
Understanding the result
API key created successfully: abc123xyz Creation Status Confirms that the API key is successfully generated.
Associated IAM Role: UserRole Role Association Displays which role the key is tied to.
Key expiration date: 2024-10-01 Expiration Info Indicates when the key will expire.
Troubleshooting
Common pitfalls
Error: IAM role not found.
Solution: Check the spelling of the IAM role name or verify that it exists.
Error: API key name already exists.
Solution: Choose a different name for the API key; names must be unique.
Error: Insufficient permissions to create API key.
Solution: Ensure your user/role has the 'iam:CreateApiKey' permission.
Command Breakdown
What each part is doing
-
exo - Base Command
- The executable that performs this operation. Here it runs Exo before the shell applies any redirect operators.
-
<api_key_name> - api key name
- The value supplied for api key name.
-
<iam_role_name> - iam role name
- The value supplied for iam role name.
Alternative Approaches
Comparable commands in other tools
Alternative cloud infrastructure tools for the same job.
gcloud compute ssh <user>@<instance> Flyctl / View Status Of Specific Application flyctl status --app <app_name> Aws / Delete Eks Cluster 1608 aws eks delete-cluster --name <cluster_name> Gh / Create Codespace Github Interactively gh cs create Cradle / Submit Elasticsearch Schema cradle elastic map