Comments (2)
Thanks for the feature request regarding the get-parameters-by-path command.
Here is related documentation on AWS CLI command line options. The request to add a --output dotenv
would likely not be considered because --output
is a global parameter used for general formatting of outputs (json, table, text) and I don't think this use case is common or general enough to warrant a new output format.
The SSM service team owns the underlying GetParametersByPath API that is used here, so we could forward a feature request to them to provide the ability to return parameters in dotenv format.
I'll also share a utility script that I think accomplishes what you're trying to do:
#!/bin/bash
# Set the parameter path prefix
PARAMETER_PATH="/"
# Fetch parameters from the Parameter Store
PARAMETERS=$(aws ssm get-parameters-by-path --path "$PARAMETER_PATH" --recursive --with-decryption --query 'Parameters[*].[Name,Value]' --output text)
DOTENV_LINES=$(echo "$PARAMETERS" | awk -F $'\t' '{ printf "%s=%s\n", $1, $2 }')
# Write the dotenv lines to a file
echo "$DOTENV_LINES" > .env
echo "Environment variables exported to .env"
Also in a Boto3 script:
import boto3
# Set up AWS credentials/configurations
session = boto3.Session()
ssm_client = session.client('ssm')
# Define the parameter path prefix
parameter_path = '/'
# Fetch parameters from the Parameter Store
response = ssm_client.get_parameters_by_path(Path=parameter_path, Recursive=True, WithDecryption=True)
# Format parameters in dotenv format
dotenv_lines = []
for parameter in response['Parameters']:
key = parameter['Name'].split('/')[-1]
value = parameter['Value']
dotenv_lines.append(f"{key}={value}")
# Write dotenv lines to a file
dotenv_file = '.env'
with open(dotenv_file, 'w') as f:
f.write('\n'.join(dotenv_lines))
print(f"Environment variables exported to {dotenv_file}")
Hope that helps — please let us know if you'd also like us to reach out to the SSM team regarding this feature request.
from aws-cli.
Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.
from aws-cli.
Related Issues (20)
- Tests of TestCLITimestampParser failing, maybe due to DST HOT 6
- Auto-update functionality for the AWS CLI MSI installer for Windows (64-bit) HOT 2
- The --boot-mode is lacking "uefi-preferred" option HOT 4
- Local environment variables interfere with tests HOT 1
- create fsx lustre file system is not working HOT 4
- AWS Chatbot commands not working yet? Could not connect to the endpoint URL HOT 5
- "aws ecr describe-image-scan-findings --max-items" does not work for enhanced image scan configuration HOT 4
- aws s3 recursive copy errors out HOT 2
- Packaging of AWS::CloudFormation::Stackset resource using AWS CLI clouformation package command HOT 2
- sso_region is ignored when region differs in profile HOT 4
- aws ecr describe-image-scan-findings with no recommendations HOT 6
- sso-region incorrect HOT 1
- Alpine 3.20 release HOT 8
- cannot import name 'SSOTokenFetcher' from 'botocore.utils' (C:\Python\Python310\lib\site-packages\botocore\utils.py)
- aws ec2 import-snapshot does not set the snapshot description
- Assume Role With Web Identity doesn't respect region HOT 2
- libpython3.11.so.1.0: pwritev2: symbol not found HOT 2
- Timestream Composite Key doesn't work
- Duplicate Example headings - sync HOT 1
- Segmentation Fault on ArmV8 with Crypto Extensions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-cli.