CI/CD

AWS CodeBuild and CodePipeline

Use Ennote secrets in AWS CodeBuild and CodePipeline: keep the Ennote token in AWS Secrets Manager, load it in buildspec.yml, install the Ennote CLI and inject secrets into build and deploy commands with ennote secret get.

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

buildspec.yml
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.

For AWS access inside the build, prefer the CodeBuild service role over AWS keys stored in Ennote. Use Ennote for credentials that AWS IAM does not cover: database passwords, third-party API keys, signing keys.

Using It in CodePipeline

CodePipeline does not run commands itself. It runs the CodeBuild project, which uses the buildspec.yml above:

  1. In your pipeline, add or edit a Build (or Deploy) stage.
  2. Choose AWS CodeBuild as the action provider and select the project.
  3. 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_staging and ENNOTE_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.