Repository: awslabs/aws-ddk (language: python)

Issue:
CICD: adding environment variable at synth stage
According to the [AWS documentation](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines-readme.html#cannot-connect-to-the-docker-daemon-at-unixvarrundockersock), I need to add a an environment variable during the synthesis stage, to use `aws-lambda-python`. However I'm not noticing an obvious way to do so.
Is there another place where I am meant to put this variable? Or has this not yet been implemented?


Discussion / hints:
At the moment there is an escape hatch that allow you to pass your own synth action to the pipeline

```javascript
.addSynthAction({synthAction: ...})
```

I believe the snippet in the docs is outdated as I can't find any construct titled `CdkPipeline()`

```javascript
const pipeline = new pipelines.CdkPipeline(this, 'MyPipeline', {
  cloudAssemblyArtifact,
  synthAction: pipelines.SimpleSynthAction.standardNpmSynth({
    sourceArtifact,
    cloudAssemblyArtifact,
    environment: {
      privileged: true,
    },
  }),
});
```

However, we should be able to pass `env` as a parameter to the [`CodeBuildStep`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines.CodeBuildStep.html#buildenvironment) created within our construct. I'll get started on a PR to get that working tomorrow. Above is the workaround for now.


I checked it out further, it might be in the `.build_pipeline()` function where you can parse `docker_enabled_for_synth`, which is the variable to use when making use of a `CodeBuildStep` construct.
But to add other environment variables other than this, I'm not sure if this is included.
If that's the property you need you should able to pass that into `.build_pipeline()` with the current construct.

[API Docs](https://constructs.dev/packages/aws-ddk-core/v/1.0.1/api/CICDPipelineStack?lang=python#buildPipeline)
<img width="1068" alt="Screen Shot 2023-07-03 at 9 15 54 AM" src="https://github.com/awslabs/aws-ddk/assets/6465221/266d51bd-f66b-4905-a1d7-b9d9356032d4">


Fix patch:
diff --git a/API.md b/API.md
index bfc5a0a8..98cdfab1 100644
--- a/API.md
+++ b/API.md
@@ -9123,6 +9123,7 @@ const getSynthActionProps: GetSynthActionProps = { ... }
 | <code><a href="#aws-ddk-core.GetSynthActionProps.property.codeartifactDomainOwner">codeartifactDomainOwner</a></code> | <code>string</code> | *No description.* |
 | <code><a href="#aws-ddk-core.GetSynthActionProps.property.codeartifactRepository">codeartifactRepository</a></code> | <code>string</code> | *No description.* |
 | <code><a href="#aws-ddk-core.GetSynthActionProps.property.codePipelineSource">codePipelineSource</a></code> | <code>aws-cdk-lib.pipelines.IFileSetProducer</code> | *No description.* |
+| <code><a href="#aws-ddk-core.GetSynthActionProps.property.env">env</a></code> | <code>{[ key: string ]: string}</code> | *No description.* |
 | <code><a href="#aws-ddk-core.GetSynthActionProps.property.partition">partition</a></code> | <code>string</code> | *No description.* |
 | <code><a href="#aws-ddk-core.GetSynthActionProps.property.region">region</a></code> | <code>string</code> | *No description.* |
 | <code><a href="#aws-ddk-core.GetSynthActionProps.property.rolePolicyStatements">rolePolicyStatements</a></code> | <code>aws-cdk-lib.aws_iam.PolicyStatement[]</code> | *No description.* |
@@ -9199,6 +9200,16 @@ public readonly codePipelineSource: IFileSetProducer;
 
 ---
 
+##### `env`<sup>Optional</sup> <a name="env" id="aws-ddk-core.GetSynthActionProps.property.env"></a>
+
+```typescript
+public readonly env: {[ key: string ]: string};
+```
+
+- *Type:* {[ key: string ]: string}
+
+---
+
 ##### `partition`<sup>Optional</sup> <a name="partition" id="aws-ddk-core.GetSynthActionProps.property.partition"></a>
 
 ```typescript
@@ -12230,6 +12241,7 @@ const synthActionProps: SynthActionProps = { ... }
 | <code><a href="#aws-ddk-core.SynthActionProps.property.codeartifactDomain">codeartifactDomain</a></code> | <code>string</code> | Name of the CodeArtifact domain. |
 | <code><a href="#aws-ddk-core.SynthActionProps.property.codeartifactDomainOwner">codeartifactDomainOwner</a></code> | <code>string</code> | CodeArtifact domain owner account. |
 | <code><a href="#aws-ddk-core.SynthActionProps.property.codeartifactRepository">codeartifactRepository</a></code> | <code>string</code> | Name of the CodeArtifact repository to pull artifacts from. |
+| <code><a href="#aws-ddk-core.SynthActionProps.property.env">env</a></code> | <code>{[ key: string ]: any}</code> | Environment variables to set. |
 | <code><a href="#aws-ddk-core.SynthActionProps.property.rolePolicyStatements">rolePolicyStatements</a></code> | <code>aws-cdk-lib.aws_iam.PolicyStatement[]</code> | Additional policies to add to the synth action role. |
 | <code><a href="#aws-ddk-core.SynthActionProps.property.synthAction">synthAction</a></code> | <code>aws-cdk-lib.pipelines.CodeBuildStep</code> | Override synth action. |
 
@@ -12296,6 +12308,18 @@ Name of the CodeArtifact repository to pull artifacts from.
 
 ---
 
+##### `env`<sup>Optional</sup> <a name="env" id="aws-ddk-core.SynthActionProps.property.env"></a>
+
+```typescript
+public readonly env: {[ key: string ]: any};
+```
+
+- *Type:* {[ key: string ]: any}
+
+Environment variables to set.
+
+---
+
 ##### `rolePolicyStatements`<sup>Optional</sup> <a name="rolePolicyStatements" id="aws-ddk-core.SynthActionProps.property.rolePolicyStatements"></a>
 
 ```typescript
diff --git a/src/cicd/actions.ts b/src/cicd/actions.ts
index 7d85f44c..84ab3c53 100644
--- a/src/cicd/actions.ts
+++ b/src/cicd/actions.ts
@@ -15,6 +15,7 @@ export interface GetSynthActionProps {
   readonly codeartifactDomain?: string;
   readonly codeartifactDomainOwner?: string;
   readonly additionalInstallCommands?: string[];
+  readonly env?: { [key: string]: string };
 }
 
 export interface CodeCommitSourceActionProps {
diff --git a/src/cicd/pipelines.ts b/src/cicd/pipelines.ts
index a33d85bd..1afdd617 100644
--- a/src/cicd/pipelines.ts
+++ b/src/cicd/pipelines.ts
@@ -51,6 +51,10 @@ export interface SynthActionProps {
    * CodeArtifact domain owner account.
    */
   readonly codeartifactDomainOwner?: string;
+  /**
+   * Environment variables to set.
+   */
+  readonly env?: { [key: string]: any };
   /**
    * Additional policies to add to the synth action role.
    */
@@ -385,6 +389,7 @@ export class CICDPipelineStack extends BaseStack {
         partition: this.partition,
         region: this.region,
         account: this.account,
+        env: props.env,
         rolePolicyStatements: props.rolePolicyStatements,
         codeartifactRepository: props.codeartifactRepository,
         codeartifactDomain: props.codeartifactDomain,


Test patch:
diff --git a/test/cicd-pipeline-stack.test.ts b/test/cicd-pipeline-stack.test.ts
index c2ae1407..4db94a92 100644
--- a/test/cicd-pipeline-stack.test.ts
+++ b/test/cicd-pipeline-stack.test.ts
@@ -563,6 +563,9 @@ test("CICDPipeline additional properties", () => {
     .addSynthAction({
       additionalInstallCommands: ["echo 'foobar'"],
       cdkVersion: "2.61.0",
+      env: {
+        FOO: "BAR",
+      },
     })
     .buildPipeline()
     .addTestStage({