Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions create-accesskeys-foruser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import boto3
import requests

def lambda_handler(event, context):
# Replace 'YOUR_USER_NAME' with the actual IAM user name
user_name = 'YOUR_USER_NAME'

# Replace 'YOUR_MULESOFT_ENDPOINT' with the actual MuleSoft endpoint URL
mulesoft_endpoint = 'YOUR_MULESOFT_ENDPOINT'

# Create an IAM client
iam = boto3.client('iam')

# Create a new access key for the user
response = iam.create_access_key(UserName=user_name)

# Extract the new access key and secret access key
access_key_id = response['AccessKey']['AccessKeyId']
secret_access_key = response['AccessKey']['SecretAccessKey']

# Prepare the payload for the MuleSoft request
payload = {
'access_key_id': access_key_id,
'secret_access_key': secret_access_key
}

# Make a POST request to the MuleSoft endpoint
response = requests.post(mulesoft_endpoint, json=payload)

# Return the MuleSoft response
return {
'statusCode': response.status_code,
'body': response.text
}
18 changes: 18 additions & 0 deletions keyvalue-store-in-secretsmgr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import boto3

def lambda_handler(event, context):
# Replace 'YOUR_SECRET_NAME' with the actual name of your secret in AWS Secrets Manager
secret_name = 'YOUR_SECRET_NAME'

# Replace 'YOUR_KEY' and 'YOUR_VALUE' with the actual key-value pair you want to store
key = 'YOUR_KEY'
value = 'YOUR_VALUE'

# Create a Secrets Manager client
client = boto3.client('secretsmanager')

# Create or update the secret with the key-value pair
response = client.put_secret_value(SecretId=secret_name, SecretString={key: value})

# Return the response
return response