Skip to content

Commit

Permalink
Simplying imports and cleaning comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gabedos committed Feb 25, 2025
1 parent 1aea243 commit 7cf5834
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 57 deletions.
17 changes: 9 additions & 8 deletions src/ecs/fargate/datadog-ecs-fargate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
import { Construct } from "constructs";
import log from "loglevel";
import { DatadogEcsFargateDefaultProps, FargateDefaultEnvVars } from "./constants";
import {
DatadogECSFargateInternalProps,
DatadogECSFargateProps,
entryPointPrefixCWS,
isOperatingSystemLinux,
mergeFargateProps,
validateECSProps,
} from "../../index";
import { DatadogECSFargateInternalProps } from "./interfaces";
import { DatadogECSFargateProps } from "../../index";
import { entryPointPrefixCWS } from "../constants";
import { EnvVarManager } from "../environment";
import { isOperatingSystemLinux, mergeFargateProps, validateECSProps } from "../utils";

export class DatadogEcsFargate extends Construct {
scope: Construct;
Expand Down Expand Up @@ -80,6 +76,11 @@ export class DatadogEcsFargate extends Construct {
envVarManager.add("DD_DOGSTATSD_ORIGIN_DETECTION_CLIENT", "true");
}

if (props.enableCWS) {
envVarManager.add("DD_RUNTIME_SECURITY_CONFIG_ENABLED", "true");
envVarManager.add("DD_RUNTIME_SECURITY_CONFIG_EBPFLESS_ENABLED", "true");
}

return envVarManager;
}

Expand Down
3 changes: 2 additions & 1 deletion src/ecs/fargate/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

import { HealthCheck } from "aws-cdk-lib/aws-ecs";
import { DatadogECSBaseProps, EnvVarManager } from "../../index";
import { EnvVarManager } from "../environment";
import { DatadogECSBaseProps } from "../interfaces";

export interface DatadogECSFargateProps extends DatadogECSBaseProps {
readonly logDriverConfiguration?: DatadogECSFargateLogDriverProps;
Expand Down
7 changes: 2 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

export * from "./datadog";
export * from "./datadog-lambda";
export * from "./ecs/fargate/datadog-ecs-fargate";
export * from "./datadog-step-functions";
export * from "./layer";
export * from "./redirect";
Expand All @@ -20,7 +19,5 @@ export * from "./interfaces";
export * from "./redirect";
export * from "./transport";
export * from "./ecs/interfaces";
export * from "./ecs/constants";
export * from "./ecs/fargate/interfaces";
export * from "./ecs/environment";
export * from "./ecs/utils";
export * from "./ecs/fargate/datadog-ecs-fargate";
export { DatadogECSFargateProps, DatadogECSFargateLogDriverProps } from "./ecs/fargate/interfaces";
46 changes: 3 additions & 43 deletions src/sample/ecs_fargate/ecs_fargate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class EcsStackBase extends cdk.Stack {

// Create a VPC with default configuration
const vpc = new ec2.Vpc(this, "EcsFargateVpc", {
maxAzs: 2, // Default is all AZs in region
maxAzs: 2,
});

// Create an ECS cluster
Expand All @@ -31,44 +31,14 @@ export class EcsStackBase extends cdk.Stack {
vpc,
});

// const keyPair = ec2.KeyPair.fromKeyPairName(this, 'KeyPair', 'gabe.dossantos.rsa');

// cluster.addCapacity('DefaultAutoScalingGroup-Linux', {
// instanceType: new ec2.InstanceType('t3.medium'),
// minCapacity: 1,
// maxCapacity: 1,
// machineImage: ecs.EcsOptimizedImage.amazonLinux2(),
// vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC },
// associatePublicIpAddress: true,
// keyName: keyPair.keyPairName,
// });

// const autoScalingGroup = new autoscaling.AutoScalingGroup(this, 'WindowsAutoScalingGroup', {
// vpc,
// instanceType: new ec2.InstanceType('t3.large'),
// machineImage: ec2.MachineImage.latestWindows(ec2.WindowsVersion.WINDOWS_SERVER_2022_ENGLISH_FULL_BASE),
// minCapacity: 1,
// maxCapacity: 1,
// vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC },
// associatePublicIpAddress: true,
// keyName: keyPair.keyPairName,
// });

// // Attach the ASG to the ECS Cluster
// const capacityProvider = new ecs.AsgCapacityProvider(this, 'WindowsCapacityProvider', {
// autoScalingGroup,
// });

// cluster.addAsgCapacityProvider(capacityProvider);

// Create an ECS task execution role
const executionRole = new iam.Role(this, "TaskExecutionRole", {
assumedBy: new iam.ServicePrincipal("ecs-tasks.amazonaws.com"),
managedPolicies: [iam.ManagedPolicy.fromAwsManagedPolicyName("service-role/AmazonECSTaskExecutionRolePolicy")],
});

// Create an ECS Fargate task definition with an nginx container
const fargateTaskDefinition = new ecs.FargateTaskDefinition(this, "NginxTaskDef", {
// Create an ECS Fargate task definition
const fargateTaskDefinition = new ecs.FargateTaskDefinition(this, "ExampleFargateTask", {
memoryLimitMiB: 2048,
cpu: 256,
executionRole: executionRole,
Expand All @@ -94,16 +64,6 @@ export class EcsStackBase extends cdk.Stack {
essential: false,
});

// const ec2windows = new ecs.TaskDefinition(this, 'WindTaskDefEC2', {
// memoryMiB: '2048',
// cpu: '1024',
// executionRole: executionRole,
// compatibility: ecs.Compatibility.EC2,
// });
// ec2windows.addContainer('WindowContEC2', {
// image: ecs.ContainerImage.fromRegistry('mcr.microsoft.com/dotnet/samples:aspnetapp-nanoserver-ltsc2022'),
// });

const fargateWindowsTaskDefinition = new ecs.FargateTaskDefinition(this, "WindowsTaskDef", {
memoryLimitMiB: 4096,
cpu: 2048,
Expand Down

0 comments on commit 7cf5834

Please sign in to comment.