AWS CodeBuild and CodePipeline
How it works
The Ennote token is kept in AWS Secrets Manager. CodeBuild loads it into ENNOTE_TOKEN through the secrets-manager section of buildspec.yml, installs the Ennote CLI, and ennote secret get <secret> -- <command> runs your commands with the keys of the secret as environment variables. CodePipeline runs the same CodeBuild project in its Build or Deploy stage. See the CI/CD overview for the common setup.
1. Create a token
Create a Personal Access Token with an expiration, and copy it.
2. Store it in AWS Secrets Manager
Store the token as a plain-text secret, in the same Region as your CodeBuild project:
aws secretsmanager create-secret \
--name ennote/ci-token \
--secret-string "<YOUR_ENNOTE_TOKEN>"
Typing the token on the command line leaves it in your shell history. You can create the secret in the AWS Console instead: Secrets Manager → Store a new secret → Other type of secret → Plaintext.
3. Allow CodeBuild to read it
Add this policy to the CodeBuild project's service role. Replace the ARN with your secret's ARN:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "secretsmanager:GetSecretValue",
"Resource": "arn:aws:secretsmanager:<region>:<account-id>:secret:ennote/ci-token-*"
}
]
}
The -* at the end matches the random suffix that Secrets Manager adds to secret ARNs. If the secret is encrypted with a customer-managed KMS key, the role also needs kms:Decrypt on that key.
4. Add the buildspec
version: 0.2
env:
variables:
ENNOTE_ORGANIZATION_ID: org_123
ENNOTE_WORKSPACE_ID: wrk_prod
ENNOTE_DO_NOT_TRACK: "1"
secrets-manager:
ENNOTE_TOKEN: ennote/ci-token
phases:
install:
commands:
- curl -sSfL https://get.ennote.io/get-cli.sh | sh
build:
commands:
- ennote secret get db-credentials -- npm run migrate
- ennote secret get aws-deploy -- ./deploy.sh
Replace org_123, wrk_prod, db-credentials and aws-deploy with your organization ID, workspace ID and secret names. CodeBuild's managed images run as root and include curl, so the install script works as is. CodeBuild masks values loaded from Secrets Manager in build logs.
Using It in CodePipeline
CodePipeline does not run commands itself. It runs the CodeBuild project, which uses the buildspec.yml above:
- In your pipeline, add or edit a Build (or Deploy) stage.
- Choose AWS CodeBuild as the action provider and select the project.
- To deploy the same project to several environments, add one action per stage and set Environment variables on each action, for example
ENNOTE_WORKSPACE_ID=wrk_stagingandENNOTE_WORKSPACE_ID=wrk_prod. Action variables override the values in the buildspec.
FAQ
Can I use Parameter Store instead of Secrets Manager?
Yes. Store the token as a SecureString parameter, give the service role ssm:GetParameters on it, and load it with parameter-store: instead of secrets-manager: in the env section.
Do I need ennote auth login?
No. With ENNOTE_TOKEN set, the CLI authenticates headlessly (ennote auth).
Need Help?
If you encounter any issues or have questions, don't hesitate to contact support. Our team is here to assist you with any challenges you might face.
TeamCity
Use Ennote secrets in TeamCity: store an Ennote token as a password parameter exposed as an environment variable, and inject secrets into build steps with ennote secret get.
Google Cloud Build
Use Ennote secrets in Google Cloud Build: keep the Ennote token in Google Secret Manager, expose it to build steps with availableSecrets and secretEnv, and inject secrets with ennote secret get.