Skip to content

Instantly share code, notes, and snippets.

Last active June 1, 2022 21:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
secretsmanager Api SecretController Complete
using Amazon.SecretsManager;
using Amazon.SecretsManager.Model;
using Microsoft.AspNetCore.Mvc;
namespace Api.Controllers;
public class SecretController : ControllerBase
private readonly IAmazonSecretsManager _secretsManager;
public SecretController(IAmazonSecretsManager secretsManager)
_secretsManager = secretsManager;
public async Task<IActionResult> GetSecret()
GetSecretValueRequest request = new GetSecretValueRequest();
request.SecretId = "test-secret";
request.VersionStage = "AWSCURRENT";
GetSecretValueResponse response = await _secretsManager.GetSecretValueAsync(request);
return Ok(new { Secret = response.SecretString });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment