-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add aws-secrets-manager example (#206)
* Add aws-secrets-manager example * Update aws-s3-folder example
- Loading branch information
1 parent
bf28b62
commit fec6fec
Showing
7 changed files
with
125 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
//> using scala "3.3.1" | ||
//> using plugin "org.virtuslab::besom-compiler-plugin:0.1.0" | ||
//> using dep "org.virtuslab::besom-core:0.1.0" | ||
//> using dep "org.virtuslab::besom-aws:6.2.1-core.0.1.0" | ||
//> using dep "org.virtuslab::besom-aws:6.2.1-core.0.1.0" | ||
//> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
### Scala an JVM | ||
*.class | ||
*.log | ||
.bsp | ||
.scala-build | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import besom.* | ||
import besom.api.aws | ||
import besom.api.aws.secretsmanager.SecretVersionArgs | ||
|
||
@main def main = Pulumi.run { | ||
// Get the Pulumi secret value | ||
val mySecret = config.getSecret("aws-secrets-manager:mySecret") | ||
|
||
// Create an AWS secret | ||
val secret = aws.secretsmanager.Secret("mySecret") | ||
|
||
// Store a new secret version | ||
val secretVersion = aws.secretsmanager.SecretVersion( | ||
"secretVersion", | ||
SecretVersionArgs( | ||
secretId = secret.id, | ||
secretString = mySecret | ||
) | ||
) | ||
|
||
for | ||
secret <- secret | ||
_ <- secretVersion | ||
yield exports( | ||
secretId = secret.id // Export secret ID (in this case the ARN) | ||
) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: aws-secrets-manager | ||
runtime: scala | ||
description: An AWS Secrets Manager example | ||
template: | ||
config: | ||
aws:region: | ||
description: The AWS region to deploy into | ||
default: us-east-1 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Setup AWS Secrets manager | ||
|
||
A simple program that creates an AWS secret and a version under AWS Secrets Manager | ||
|
||
## Prerequisites | ||
|
||
[Follow the instructions](https://www.pulumi.com/docs/clouds/aws/get-started/begin/) | ||
to get started with Pulumi & AWS. | ||
|
||
## Deploying and running the program | ||
|
||
Note: some values in this example will be different from run to run. | ||
These values are indicated with `***`. | ||
|
||
1. Create a new stack, which is an isolated deployment target for this example: | ||
|
||
```bash | ||
pulumi stack init aws-secrets-manager-dev | ||
``` | ||
|
||
2. Set the AWS region: | ||
|
||
```bash | ||
pulumi config set aws:region us-west-2 | ||
``` | ||
|
||
3. Create a Pulumi secret that will be saved in the secret manager: | ||
|
||
```bash | ||
pulumi config set --secret mySecret | ||
``` | ||
|
||
4. Run `pulumi up` to preview and deploy changes. After the preview is shown | ||
you will be prompted if you want to continue or not. | ||
|
||
```bash | ||
pulumi up | ||
``` | ||
|
||
After a couple of minutes, your VM will be ready. Your web server will start on port `80`. | ||
|
||
5. To see the resources that were created, run `pulumi stack output`: | ||
|
||
```bash | ||
pulumi stack output | ||
``` | ||
|
||
6. From there, feel free to experiment. Simply making edits and running pulumi up will incrementally update your infrastructure. | ||
|
||
7. To clean up resources, destroy your stack and remove it: | ||
|
||
```bash | ||
pulumi destroy | ||
``` | ||
```bash | ||
pulumi stack rm aws-secrets-manager-dev | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//> using scala "3.3.1" | ||
//> using plugin "org.virtuslab::besom-compiler-plugin:0.1.0" | ||
//> using dep "org.virtuslab::besom-core:0.1.0" | ||
//> using dep "org.virtuslab::besom-aws:6.2.1-core.0.1.0" | ||
//> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement |