Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
23 changes: 23 additions & 0 deletions create-accesskeys-foruser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import boto3

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

# 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']

# Return the new access key details
return {
'AccessKeyId': access_key_id,
'SecretAccessKey': secret_access_key
}

#Make sure to replace 'YOUR_USER_NAME' with the actual IAM user
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