class InitService
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.EC2.InitService |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsec2#InitService |
![]() | software.amazon.awscdk.services.ec2.InitService |
![]() | aws_cdk.aws_ec2.InitService |
![]() | aws-cdk-lib » aws_ec2 » InitService |
Extends
Init
A services that be enabled, disabled or restarted when the instance is launched.
Example
declare const myBucket: s3.Bucket;
const handle = new ec2.InitServiceRestartHandle();
ec2.CloudFormationInit.fromElements(
ec2.InitFile.fromString('/etc/nginx/nginx.conf', '...', { serviceRestartHandles: [handle] }),
ec2.InitSource.fromS3Object('/var/www/html', myBucket, 'html.zip', { serviceRestartHandles: [handle] }),
ec2.InitService.enable('nginx', {
serviceRestartHandle: handle,
})
);
Properties
Name | Type | Description |
---|---|---|
element | string | Returns the init element type for this element. |
elementType
Type:
string
Returns the init element type for this element.
Methods
Name | Description |
---|---|
static disable(serviceName) | Disable and stop the given service. |
static enable(serviceName, options?) | Enable and start the given service, optionally restarting it. |
static systemd | Install a systemd-compatible config file for the given service. |
static disable(serviceName)
public static disable(serviceName: string): InitService
Parameters
- serviceName
string
Returns
Disable and stop the given service.
static enable(serviceName, options?)
public static enable(serviceName: string, options?: InitServiceOptions): InitService
Parameters
- serviceName
string
- options
Init
Service Options
Returns
Enable and start the given service, optionally restarting it.
static systemdConfigFile(serviceName, options)
public static systemdConfigFile(serviceName: string, options: SystemdConfigFileOptions): InitFile
Parameters
- serviceName
string
- options
Systemd
Config File Options
Returns
Install a systemd-compatible config file for the given service.
This is a helper function to create a simple systemd configuration
file that will allow running a service on the machine using InitService.enable()
.
Systemd allows many configuration options; this function does not pretend
to expose all of them. If you need advanced configuration options, you
can use InitFile
to create exactly the configuration file you need
at /etc/systemd/system/${serviceName}.service
.