Skip to content

[Feature Request] Cloud Compute Defined Environment Variables #833

Description

@bestickley

Description

I deploy my compute workloads to AWS Lambda and ECS Fargate. I use the AWS CDK to define my functions/containers, including environment variables. Example:

const fn = new nodejs.NodejsFunction(this, 'MyFunction', {
  entry: '/path/to/my/file.ts',
  environment: {
    ENVIRONMENT: "prod",
    FEATURE_FLAG_1: "1",
});
// external param
const apiUrlParam = ssm.StringParameter.fromStringParameterAttributes(this, 'ImportedApiUrl', {
      parameterName: '/config/api_url',
    });
fn.addEnvironment("MY_API_KEY", apiUrlParam.stringValue);
apiUrlParam.grantRead(fn);
// external secret
const mySecret = secretsmanager.Secret.fromSecretNameV2(
      this, 
      'ImportedSecret', 
      'my-api-credentials'
    );
fn.addEnvironment("MY_API_CREDS_ARN", mySecret.secretArn);
mySecret.grantRead(fn);

Now, I have to duplicate all of this in my local .env.schema for varlock to read env vars. BUT, what if varlock could resolve all of this for me?

Motivation

I don't want to have to duplicate env var configuration across my infrastructure-as-code + varlock.

Proposed Solution

.env.schema

# @plugin(@varlock/aws-lambda-env-plugin, "MyLambdaFunction")
# @initAws(region=$AWS_REGION, profile=$AWS_PROFILE)
# ---

# Environment from my AWS Lambda function are automatically resolved. Yay!

Notice the plugin needs to set multiple env vars. The plugin would look up the lambda function, then find the configuration that defines the environment variables, resolve them (sometimes reaching out to SSM or SecretsManager in the process), and set them locally.

Alternatives

Duplicate environment configuration.

Additional Information

Would be great to also have this for ECS (Containers Service). You'd want to resolve the ECS Task Definition which contains environment configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions