Skip to main content

Package to create a SecretsManager's secret with auto rotation.

Project description

AWS Secret Cdk

An AWS CDK library to manage SecretsManager secrets easily.

Description

SecretsManager is a great AWS service to manage your secrets e.g. database password. It is really easy to create and configure a secret through AWS console (UI). However it is NOTORIOUSLY difficult to create and manage secrets through CloudFormation. You need to create a lambda function, which executes secret rotation, ensure correct lambda function permissions and security groups, correctly configure secrets themselves with correct templates, etc. All in all, it is really painful. This library tackles this problem. In a nutshell, you just provide a database, for which the secret should be applied, and some other params. And that's it! You're good to go.

Assumptions

This Cdk library assumes the following:

  • You have knowledge in AWS
  • You have knowledge in AWS CloudFormation and AWS CDK for creating infrastructure-as-a-code.

How to use

# Suppose you have a stack (core.Stack) or an app (core.App) which are constructs.
from aws_cdk.core import Stack
from aws_cdk.aws_ec2 import Vpc
class MyStack(Stack):
    def __init__(self):
        super().__init__(...)

        # Suppose you have defined a VPC:
        self.vpc = Vpc(...)

        # Suppose you have a database (or a cluster)
        from aws_cdk import aws_rds
        self.database = aws_rds.CfnDBCluster(...)

        # Now simply create a secret with 30 day rotation.
        from aws_secret_cdk.rds_secret import RdsSecret
        from aws_secret_cdk.vpc_parameters import VPCParameters
        self.rds_secret = RdsSecret(
            stack=self,
            prefix='MyResourcesPrefix',
            vpc_parameters=VPCParameters(
                rotation_lambda_vpc=self.vpc,
                rotation_lambda_security_groups=[
                    # Your SG's.
                ],
                rotation_lambda_subnets=self.vpc.private_subnets
            ),
            database=self.database
        )

Release history

2.0.2

Add docstrings.

2.0.1

Fix target types and target arns.

2.0.0

General bug fixes. Add permission for KMS key resource. Add secret template.

1.0.9

Add secrets manager as a valid principal to invoke rotation lambda.

1.0.8

Add S3 removal policy.

1.0.7

Don't use managed policies.

1.0.6

Aws Lambda dependency update.

1.0.5

Aws Lambda dependency update.

1.0.4

Dont create Code class instance.

1.0.3

Move packages into main package.

1.0.2

Fix manifest file.

1.0.1

Ensure bucket and bucket deployment has different names.

1.0.0

Initial commit. Add ability to create RDS secret and rotate it every 30 days.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws_secret_cdk-2.0.2.tar.gz (68.0 kB view details)

Uploaded Source

Built Distribution

aws_secret_cdk-2.0.2-py3-none-any.whl (66.0 kB view details)

Uploaded Python 3

File details

Details for the file aws_secret_cdk-2.0.2.tar.gz.

File metadata

  • Download URL: aws_secret_cdk-2.0.2.tar.gz
  • Upload date:
  • Size: 68.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/2.7.15+

File hashes

Hashes for aws_secret_cdk-2.0.2.tar.gz
Algorithm Hash digest
SHA256 5f095a36811b656153241e0dd09c6e12c495a1bbfa4957031dded2850bede741
MD5 deac0294aac4990e534cfdf50e75e006
BLAKE2b-256 f974a8d5be8033fdec9e2ffc8adf652a2a8170556c71c2d02f1b4d85a552e0cf

See more details on using hashes here.

File details

Details for the file aws_secret_cdk-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: aws_secret_cdk-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 66.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/2.7.15+

File hashes

Hashes for aws_secret_cdk-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8c59016374b7b903dabfa37e02c8b1465499d9835b7e61bf99370a4c8124b4da
MD5 94a5025a2fd5cb20ddcb7c88a4d97d52
BLAKE2b-256 037d3bb90a2a9f828ed5012b81382ce5ae3feb4862ae2d04cf7450f504eda92d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page