Skip to content

Commit

Permalink
Updated Amplify doc to add sdk v3 code (#7674)
Browse files Browse the repository at this point in the history
* added sdk v3 code

* updated the sdk v3 code as per the suggestions

---------

Co-authored-by: meghasv09 <meghasomaradder2@gmail.com>
  • Loading branch information
meghasv09 and megh2000 authored Jun 10, 2024
1 parent 3748cac commit 414fcac
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ To access the secret values in your Lambda function, use the [AWS SSM GetParamet

If your Lambda function is using the Node.js runtime, a comment block will be placed at the top of your `index.js` file with example code to retrieve the secret values.

<BlockSwitcher>

<Block name='AWS SDK V2'>

```js
const aws = require('aws-sdk');

Expand All @@ -89,6 +93,35 @@ const { Parameters } = await (new aws.SSM())

// Parameters will be of the form { Name: 'secretName', Value: 'secretValue', ... }[]
```
</Block>

<Block name='AWS SDK V3'>

```js
const { SSMClient, GetParametersCommand } = require("@aws-sdk/client-ssm");

const client = new SSMClient();

const command = new GetParametersCommand({
Names: ["EXAMPLE_SECRET_1", "EXAMPLE_SECRET_2"].map(
(secretName) => process.env[secretName]
),
WithDecryption: true,
});

client
.send(command)
.then((response) => {
const { Parameters } = response;
console.log(Parameters);
})
.catch((error) => {
console.error(error);
});
```
</Block>

</BlockSwitcher>

## Multi-environment flows
When creating a new Amplify environment using `amplify env add`, Amplify CLI asks if you want to apply all secret values to the new environment or modify them. If you choose to apply the existing values, you can still make edits anytime using `amplify update function`.
Expand Down

0 comments on commit 414fcac

Please sign in to comment.