From be5303c19ac4e362ee9ae8736b6e031ca1504478 Mon Sep 17 00:00:00 2001 From: Razin Idzuddin Date: Sun, 31 Mar 2024 22:27:57 +1100 Subject: [PATCH] add example to use environment parameters --- packages/aws-cdk-lib/aws-ec2/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/aws-cdk-lib/aws-ec2/README.md b/packages/aws-cdk-lib/aws-ec2/README.md index 24fb39b3605c0..bf96ae34c7c4f 100644 --- a/packages/aws-cdk-lib/aws-ec2/README.md +++ b/packages/aws-cdk-lib/aws-ec2/README.md @@ -1426,6 +1426,22 @@ ec2.CloudFormationInit.fromElements( ); ``` +If your services require environment variables, you can use the `environmentVariables` or `environmentFiles` +parameter to do so: +```ts +new ec2.InitConfig([ + ec2.InitFile.fromString('/myvars.env', 'VAR_FROM_FILE="VAR_FROM_FILE"'), + ec2.InitService.systemdConfigFile('myapp', { + command: '/usr/bin/python3 -m http.server 8080', + cwd: '/var/www/html', + environmentVariables: { + MY_VAR: 'MY_VAR', + }, + environmentFiles: ['/myvars.env'], + }), +]) +``` + ### Bastion Hosts A bastion host functions as an instance used to access servers and resources in a VPC without open up the complete VPC on a network level.