Skip to content

Commit

Permalink
Add a example for secretmanager.SecretVersion (#3079)
Browse files Browse the repository at this point in the history
This example shows how to add multiple secrets via a json KV blob.

Fixes #3042
  • Loading branch information
iwahbe authored Dec 2, 2023
1 parent 3adb3ac commit f37b7cc
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/bucket-py/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pulumi>=3.0.0,<4.0.0
pulumi_aws>=5.0.0,<6.0.0
pulumi_aws>=6.0.0,<7.0.0
10 changes: 9 additions & 1 deletion examples/examples_py_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func TestAccBucketPy(t *testing.T) {
func TestAccWebserverPy(t *testing.T) {
for _, dir := range []string{"webserver-py", "webserver-py-old"} {
t.Run(dir, func(t *testing.T) {

test := getPythonBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: filepath.Join(getCwd(t), dir),
Expand Down Expand Up @@ -59,6 +58,15 @@ func TestAccFifoSqsQueuePy(t *testing.T) {
integration.ProgramTest(t, &test)
}

func TestSecretManagerPy(t *testing.T) {
test := getPythonBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: filepath.Join(getCwd(t), "secretmanager"),
})

integration.ProgramTest(t, &test)
}

func getPythonBaseOptions(t *testing.T) integration.ProgramTestOptions {
envRegion := getEnvRegion(t)
base := getBaseOptions()
Expand Down
3 changes: 3 additions & 0 deletions examples/secretmanager/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: secretmanager-py
runtime: python
description: A simple example of using the Secret Manager APIs using Python.
24 changes: 24 additions & 0 deletions examples/secretmanager/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import json
from pulumi_aws.secretsmanager import Secret, SecretVersion

# Create an AWS Secret for RDS
rds_secret = Secret("db",
description="RDS Database secret",
kms_key_id="alias/aws/secretsmanager", # default KMS key
)

# Define the secret value
secret_string = json.dumps({
"username": "username",
"password": "password",
"engine": "mysql",
"host": "<endpoint>",
"port": 3306,
"dbname": "<db_name>",
})

# Create a secret version in AWS Secrets Manager with the secret value
rds_secret_version = SecretVersion("version",
secret_id=rds_secret.id,
secret_string=secret_string,
)
2 changes: 2 additions & 0 deletions examples/secretmanager/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pulumi>=3.0.0,<4.0.0
pulumi_aws>=6.0.0,<7.0.0
2 changes: 1 addition & 1 deletion examples/sqs-fifo-queue/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pulumi>=3.0.0,<4.0.0
pulumi_aws>=5.0.0,<6.0.0
pulumi_aws>=6.0.0,<7.0.0
2 changes: 1 addition & 1 deletion examples/webserver-py-old/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pulumi>=3.0.0,<4.0.0
pulumi_aws>=5.0.0,<6.0.0
pulumi_aws>=6.0.0,<7.0.0
2 changes: 1 addition & 1 deletion examples/webserver-py/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pulumi>=3.0.0,<4.0.0
pulumi_aws>=5.0.0,<6.0.0
pulumi_aws>=6.0.0,<7.0.0

0 comments on commit f37b7cc

Please sign in to comment.