Created
September 6, 2024 19:05
-
-
Save JoKenPo/a3d60fd1b464acb68977d2ba3f66a743 to your computer and use it in GitHub Desktop.
localstack.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const AWS = require('aws-sdk'); | |
| // Configurando o SSM para usar o LocalStack | |
| const ssm = new AWS.SSM({ | |
| endpoint: 'http://localhost:4566', // Endpoint do LocalStack | |
| region: 'us-east-1', // Região que você definiu | |
| accessKeyId: 'test', // Credenciais fictícias para usar localmente | |
| secretAccessKey: 'test', | |
| }); | |
| // Exemplo de uso: criar um parâmetro no SSM | |
| const putParameter = async () => { | |
| const params = { | |
| Name: '/my/parameter', | |
| Value: 'test-value', | |
| Type: 'String', | |
| }; | |
| try { | |
| const result = await ssm.putParameter(params).promise(); | |
| console.log('Parâmetro criado:', result); | |
| } catch (err) { | |
| console.error('Erro ao criar parâmetro:', err); | |
| } | |
| }; | |
| // Exemplo de uso: buscar um parâmetro no SSM | |
| const getParameter = async () => { | |
| const params = { | |
| Name: '/my/parameter', | |
| }; | |
| try { | |
| const result = await ssm.getParameter(params).promise(); | |
| console.log('Parâmetro recuperado:', result.Parameter); | |
| } catch (err) { | |
| console.error('Erro ao recuperar parâmetro:', err); | |
| } | |
| }; | |
| putParameter(); | |
| getParameter(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment