diff --git a/create-accesskeys-foruser.py b/create-accesskeys-foruser.py new file mode 100644 index 0000000..b635c8d --- /dev/null +++ b/create-accesskeys-foruser.py @@ -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 + } diff --git a/keyvalue-store-in-secretsmgr.py b/keyvalue-store-in-secretsmgr.py new file mode 100644 index 0000000..ced458a --- /dev/null +++ b/keyvalue-store-in-secretsmgr.py @@ -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