aws-cdk-lib.aws_ec2.SystemdConfigFileOptions

interface SystemdConfigFileOptions

LanguageType name
.NETAmazon.CDK.AWS.EC2.SystemdConfigFileOptions
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsec2#SystemdConfigFileOptions
Javasoftware.amazon.awscdk.services.ec2.SystemdConfigFileOptions
Pythonaws_cdk.aws_ec2.SystemdConfigFileOptions
TypeScript (source)aws-cdk-lib » aws_ec2 » SystemdConfigFileOptions

Options for creating a SystemD configuration file.

Example

declare const vpc: ec2.Vpc;
declare const instanceType: ec2.InstanceType;

new ec2.Instance(this, 'Instance', {
  vpc,
  instanceType,
  machineImage: ec2.MachineImage.latestAmazonLinux2022(),

  init: ec2.CloudFormationInit.fromElements(
    // Create a simple config file that runs a Python web server
    ec2.InitService.systemdConfigFile('simpleserver', {
      command: '/usr/bin/python3 -m http.server 8080',
      cwd: '/var/www/html',
    }),
    // Start the server using SystemD
    ec2.InitService.enable('simpleserver', {
      serviceManager: ec2.ServiceManager.SYSTEMD,
    }),
    // Drop an example file to show the web server working
    ec2.InitFile.fromString('/var/www/html/index.html', 'Hello! It\'s working!'),
  ),
});

Properties

NameTypeDescription
commandstringThe command to run to start this service.
afterNetwork?booleanStart the service after the networking part of the OS comes up.
cwd?stringThe working directory for the command.
description?stringA description of this service.
group?stringThe group to execute the process under.
keepRunning?booleanKeep the process running all the time.
user?stringThe user to execute the process under.

command

Type: string

The command to run to start this service.


afterNetwork?

Type: boolean (optional, default: true)

Start the service after the networking part of the OS comes up.


cwd?

Type: string (optional, default: Root directory or home directory of specified user)

The working directory for the command.


description?

Type: string (optional, default: No description)

A description of this service.


group?

Type: string (optional, default: root)

The group to execute the process under.


keepRunning?

Type: boolean (optional, default: true)

Keep the process running all the time.

Restarts the process when it exits for any reason other than the machine shutting down.


user?

Type: string (optional, default: root)

The user to execute the process under.