I've followed this tutorial to set up CDK Pipelines using Python with a trigger from Github.
It looks something like this:
import aws_cdk as cdk
from constructs import Construct
from aws_cdk.pipelines import CodePipeline, CodePipelineSource, ShellStep
from my_pipeline.my_pipeline_app_stage import MyPipelineAppStage
class MyPipelineStack(cdk.Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
pipeline = CodePipeline(self, "Pipeline",
pipeline_name="MyPipeline",
synth=ShellStep("Synth",
input=CodePipelineSource.git_hub("OWNER/REPO", "main"),
commands=[
"npm install -g aws-cdk",
"python -m pip install -r requirements.txt",
"cdk synth"]))
pipeline.add_stage(MyPipelineAppStage(self, "my-stack"))
I want to be able to get custom environment variables from my CDK stack. For example:
organizational_unit_ids=[
os.environ.get("OU_ID"),
]
I don't want to store these environment variables directly in my code. Now my question is, where should I store these environment variables in order for the synth
ShellStep
to use them?
Should I add them manually to the CodeBuild action after it has been created?
Or is there somewhere central I can store them?