-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparameter_store_lambda_function.py
50 lines (44 loc) · 1.15 KB
/
parameter_store_lambda_function.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import json
import os
import boto3
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
print('Loading function')
#Updates an SSM parameter
#Expects parameterName, parameterValue
def lambda_handler(event, context):
json_event = json.dumps(event)
print("--event: " + json_event)
# get SSM client
client = boto3.client('ssm')
parameterName = event['detail']['name']
# Get the parameter store value
response = client.get_parameter(
Name=parameterName,
WithDecryption=False
)
print(response)
return {"Data" : response["Parameter"]["Value"]}
"""
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ssm:PutParameter",
"Resource": "arn:aws:ssm:us-east-2:855918939771:parameter/s3-bucket-for-app"
},
{
"Effect": "Allow",
"Action": "ssm:GetParameter",
"Resource": "arn:aws:ssm:us-east-2:855918939771:parameter/s3-bucket-for-app"
},
{
"Effect": "Allow",
"Action": "ssm:DescribeParameters",
"Resource": "*"
}
]
}
"""