ExecuteCommandLogConfiguration Struct
The log configuration for the results of the execute command actions.
The logs can be sent to CloudWatch Logs and/ or an Amazon S3 bucket. For more information, see [ExecuteCommandLogConfiguration] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-cluster-executecommandlogconfiguration.html
Example
ts
declare const vpc: ec2.Vpc;
const kmsKey = new kms.Key(this, 'KmsKey');
// Pass the KMS key in the `encryptionKey` field to associate the key to the log group
const logGroup = new logs.LogGroup(this, 'LogGroup', {
encryptionKey: kmsKey,
});
// Pass the KMS key in the `encryptionKey` field to associate the key to the S3 bucket
const execBucket = new s3.Bucket(this, 'EcsExecBucket', {
encryptionKey: kmsKey,
});
const cluster = new ecs.Cluster(this, 'Cluster', {
vpc,
executeCommandConfiguration: {
kmsKey,
logConfiguration: {
cloudWatchLogGroup: logGroup,
cloudWatchEncryptionEnabled: true,
s3Bucket: execBucket,
s3EncryptionEnabled: true,
s3KeyPrefix: 'exec-command-output',
},
logging: ecs.ExecuteCommandLogging.OVERRIDE,
},
});
python
# vpc: ec2.Vpc
kms_key = kms.Key(self, "KmsKey")
# Pass the KMS key in the `encryptionKey` field to associate the key to the log group
log_group = logs.LogGroup(self, "LogGroup",
encryption_key=kms_key
)
# Pass the KMS key in the `encryptionKey` field to associate the key to the S3 bucket
exec_bucket = s3.Bucket(self, "EcsExecBucket",
encryption_key=kms_key
)
cluster = ecs.Cluster(self, "Cluster",
vpc=vpc,
execute_command_configuration=ecs.ExecuteCommandConfiguration(
kms_key=kms_key,
log_configuration=ecs.ExecuteCommandLogConfiguration(
cloud_watch_log_group=log_group,
cloud_watch_encryption_enabled=True,
s3_bucket=exec_bucket,
s3_encryption_enabled=True,
s3_key_prefix="exec-command-output"
),
logging=ecs.ExecuteCommandLogging.OVERRIDE
)
)
java
Vpc vpc;
Key kmsKey = new Key(this, "KmsKey");
// Pass the KMS key in the `encryptionKey` field to associate the key to the log group
LogGroup logGroup = LogGroup.Builder.create(this, "LogGroup")
.encryptionKey(kmsKey)
.build();
// Pass the KMS key in the `encryptionKey` field to associate the key to the S3 bucket
Bucket execBucket = Bucket.Builder.create(this, "EcsExecBucket")
.encryptionKey(kmsKey)
.build();
Cluster cluster = Cluster.Builder.create(this, "Cluster")
.vpc(vpc)
.executeCommandConfiguration(ExecuteCommandConfiguration.builder()
.kmsKey(kmsKey)
.logConfiguration(ExecuteCommandLogConfiguration.builder()
.cloudWatchLogGroup(logGroup)
.cloudWatchEncryptionEnabled(true)
.s3Bucket(execBucket)
.s3EncryptionEnabled(true)
.s3KeyPrefix("exec-command-output")
.build())
.logging(ExecuteCommandLogging.OVERRIDE)
.build())
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Vpc vpc;
var kmsKey = new Key(this, "KmsKey");
// Pass the KMS key in the `encryptionKey` field to associate the key to the log group
var logGroup = new LogGroup(this, "LogGroup", new LogGroupProps {
EncryptionKey = kmsKey
});
// Pass the KMS key in the `encryptionKey` field to associate the key to the S3 bucket
var execBucket = new Bucket(this, "EcsExecBucket", new BucketProps {
EncryptionKey = kmsKey
});
var cluster = new Cluster(this, "Cluster", new ClusterProps {
Vpc = vpc,
ExecuteCommandConfiguration = new ExecuteCommandConfiguration {
KmsKey = kmsKey,
LogConfiguration = new ExecuteCommandLogConfiguration {
CloudWatchLogGroup = logGroup,
CloudWatchEncryptionEnabled = true,
S3Bucket = execBucket,
S3EncryptionEnabled = true,
S3KeyPrefix = "exec-command-output"
},
Logging = ExecuteCommandLogging.OVERRIDE
}
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var vpc Vpc
kmsKey := kms.NewKey(this, jsii.String("KmsKey"))
// Pass the KMS key in the `encryptionKey` field to associate the key to the log group
logGroup := logs.NewLogGroup(this, jsii.String("LogGroup"), &LogGroupProps{
EncryptionKey: kmsKey,
})
// Pass the KMS key in the `encryptionKey` field to associate the key to the S3 bucket
execBucket := s3.NewBucket(this, jsii.String("EcsExecBucket"), &BucketProps{
EncryptionKey: kmsKey,
})
cluster := ecs.NewCluster(this, jsii.String("Cluster"), &ClusterProps{
Vpc: Vpc,
ExecuteCommandConfiguration: &ExecuteCommandConfiguration{
KmsKey: *KmsKey,
LogConfiguration: &ExecuteCommandLogConfiguration{
CloudWatchLogGroup: logGroup,
CloudWatchEncryptionEnabled: jsii.Boolean(true),
S3Bucket: execBucket,
S3EncryptionEnabled: jsii.Boolean(true),
S3KeyPrefix: jsii.String("exec-command-output"),
},
Logging: ecs.ExecuteCommandLogging_OVERRIDE,
},
})
Properties
cloudWatchEncryptionEnabledoptionalbooleancloud_watch_encryption_enabledoptionalboolcloudWatchEncryptionEnabledoptionalBooleanCloudWatchEncryptionEnabledoptionalboolCloudWatchEncryptionEnabledoptional*bool#Whether or not to enable encryption on the CloudWatch logs.
Default: encryption will be disabled.
cloudWatchLogGroupoptionalILogGroupRefcloud_watch_log_groupoptionalILogGroupRefcloudWatchLogGroupoptionalILogGroupRefCloudWatchLogGroupoptionalILogGroupRefCloudWatchLogGroupoptionalILogGroupRef= none#The name of the CloudWatch log group to send logs to.
The CloudWatch log group must already be created.
s3BucketoptionalIBuckets3_bucketoptionalIBuckets3BucketoptionalIBucketS3BucketoptionalIBucketS3BucketoptionalIBucket= none#The name of the S3 bucket to send logs to.
The S3 bucket must already be created.
s3EncryptionEnabledoptionalbooleans3_encryption_enabledoptionalbools3EncryptionEnabledoptionalBooleanS3EncryptionEnabledoptionalboolS3EncryptionEnabledoptional*bool#Whether or not to enable encryption on the S3 bucket.
Default: encryption will be disabled.
s3KeyPrefixoptionalstrings3_key_prefixoptionalstrs3KeyPrefixoptionalStringS3KeyPrefixoptionalstringS3KeyPrefixoptional*string= none#An optional folder in the S3 bucket to place logs in.