AWS Secrets Manager
Attention Magers: This classified document contains vital intel on securing sensitive data within the AWS Secrets Manager vault. Study the protocols carefully to create and operationalize confidential secrets, granting you clearance to integrate them into your Mage data pipeline projects.
Creating a New Secret in AWS Secrets Manager
Before you can use AWS Secrets Manager with Mage, you need to create a new secret in the AWS Secrets Manager console. Follow these steps:
- Open the AWS Secrets Manager console
- Click “Store a new secret.”
- On the “Choose Secret Type” page, select the appropriate secret type for your use case, and then click “Next.”
- On the “Configure Secret” page, provide the necessary details for your secret, such as the key-value pairs or the plaintext value, and then click “Next.”
- (Optional) On the “Configure Rotation” page, you can enable automatic rotation for your secret. Automatic rotation periodically updates the secret value, ensuring that your sensitive data remains secure. Configure the rotation settings according to your requirements, and then click “Next.”
- Review the secret details on the “Review” page, and if everything looks correct, click “Store.”
Your new secret is now stored in AWS Secrets Manager. Make a note of the secret’s ARN (Amazon Resource Name), as you’ll need it to access the secret from Mage.
For more detailed information on managing and storing secrets in AWS Secrets Manager, refer to the official AWS Documentation
Working with Secrets in Mage
Mage works with AWS secrets in two ways: directly accessing them through Python code, and referencing them in YAML configuration files using placeholders that Mage resolves at runtime.
Python:
To use secrets in Python code, read these instructions.
YAML:
Working with AWS Secrets Manager
If you need a more secure environment for handling sensitive data, you can directly integrate your YAML files with AWS Secrets Manager. For example, to reference a secret stored in AWS Secrets Manager with the ARN, you would use the following syntax in your YAML file:
AWS_SECRET_ACCESS_KEY = arn:aws:secretsmanager:<AWS Region>:<AWS Account ID>:secret:<AWS_SECRET_ACCESS_KEY Name>
By integrating with AWS Secrets Manager, you can ensure that your sensitive data is securely stored and accessed throughout your Mage data pipelines.
- AWS_SECRET_ACCESS_KEY: The secret value you want get from AWS Secrets Manager
- arn: This is a prefix that identifies the resource as an ARN.
- aws: This is the partition that the resource is in. In this case, it’s the AWS partition.
- secretsmanager: This is the service namespace, which identifies the AWS service. In this case, it’s the AWS Secrets Manager service.
- AWS Region: This is the AWS region where the secret is stored (i.e. us-west-2).
- AWS Account ID: This is the 12-digit AWS account ID that the secret belongs to.
- secret This is the resource type, which indicates that the resource is a secret.
- AWS_SECRET_ACCESS_KEY Name: This is the friendly name or ID of the specific secret you want to reference. It can include alphanumeric characters, hyphens, and underscores.
In the context of the YAML file, this ARN is being used with the syntax to reference the secret value stored in AWS Secrets Manager. The YAML file itself does not contain the actual secret value; instead, it references the secret by its ARN.