# HG changeset patch # User Dennis Concepcion Martin # Date 1631808206 -7200 # Node ID cfd87657000884b04ef38e5fcea57eef333972dd # Parent 5c36f51105c2113a861debac18a60804958a57bb attach inline policy to function to access screts diff -r 5c36f51105c2 -r cfd876570008 src/handlers/sentiment.py --- a/src/handlers/sentiment.py Thu Sep 16 16:51:59 2021 +0200 +++ b/src/handlers/sentiment.py Thu Sep 16 18:03:26 2021 +0200 @@ -20,12 +20,12 @@ bearer_token = twitter_key['BEARER'] twitter_header = {"Authorization": "Bearer {}".format(bearer_token)} # Auth header twitter_response = requests.request("GET", twitter_url, headers=twitter_header) - print(twitter_response.json()) return { "statusCode": 200, "body": json.dumps({ "message": "hello world", + "tweets": twitter_response.json() }), } diff -r 5c36f51105c2 -r cfd876570008 template.yaml --- a/template.yaml Thu Sep 16 16:51:59 2021 +0200 +++ b/template.yaml Thu Sep 16 18:03:26 2021 +0200 @@ -157,6 +157,10 @@ CodeUri: src/ Handler: handlers/sentiment.get_tweet_sentiment Runtime: python3.9 + Policies: + - AWSSecretsManagerGetSecretValuePolicy: + SecretArn: + arn:aws:secretsmanager:eu-west-2:339008578167:secret:tweet-analysis-keys-gKo6DQ Events: CallGetTweetSentiment: Type: Api