Skip to content

Instantly share code, notes, and snippets.

@JoKenPo
Created September 6, 2024 19:05
Show Gist options
  • Save JoKenPo/a3d60fd1b464acb68977d2ba3f66a743 to your computer and use it in GitHub Desktop.
Save JoKenPo/a3d60fd1b464acb68977d2ba3f66a743 to your computer and use it in GitHub Desktop.

Revisions

  1. JoKenPo created this gist Sep 6, 2024.
    42 changes: 42 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    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();