AWS Code Sample
Catalog

secret-resource-access-staging-label.py

Accesses a specific version of a secret on the core.

# Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). You # may not use this file except in compliance with the License. A copy of # the License is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file accompanying this file. This file is # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. # # This sample is used in the AWS IoT Greengrass Developer Guide: # https://docs.aws.amazon.com/greengrass/latest/developerguide/secrets-using.html # import greengrasssdk # Creating a greengrass core sdk client client = greengrasssdk.client('secretsmanager') # This handler is called when the function is invoked # It uses the secretsmanager client to get the value of a specific secret version def function_handler(event, context): response = client.get_secret_value(SecretId='greengrass-MySecret-abc', VersionStage='MyTargetLabel') raw_secret = response.get('SecretString')

Sample Details

Service: greengrass

Last tested: 2019-01-03

Author: AWS

Type: snippet

On this page: