Skip to content

Commit

Permalink
CDK update with otel collector image
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Kurait <akurait@amazon.com>
  • Loading branch information
AndreKurait committed Oct 18, 2024
1 parent f04f2a7 commit 1c377a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,14 @@ export function makeLocalAssetContainerImage(scope: Construct, imageName: string
const dockerfileContent = `
FROM ${imageName}
`;

writeFileSync(dockerfilePath, dockerfileContent);
const asset = new DockerImageAsset(scope, 'ServiceImage', {
const assetName = `${sanitizedImageName.charAt(0).toUpperCase() + sanitizedImageName.slice(1)}ImageAsset`;
const asset = new DockerImageAsset(scope, assetName, {
directory: tempDir,
// add the tag to the hash so that the asset is invalidated when the tag changes
extraHash: imageHash,
assetName: assetName,
});
return ContainerImage.fromDockerImageAsset(asset);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
TaskDefinition
} from "aws-cdk-lib/aws-ecs";
import {LogGroup, RetentionDays} from "aws-cdk-lib/aws-logs";
import {createAwsDistroForOtelPushInstrumentationPolicy} from "../common-utilities";
import {createAwsDistroForOtelPushInstrumentationPolicy, makeLocalAssetContainerImage} from "../common-utilities";
import {Duration, RemovalPolicy} from "aws-cdk-lib";
import { DockerImageAsset } from "aws-cdk-lib/aws-ecr-assets";
import { join } from "path";
Expand Down Expand Up @@ -41,9 +41,7 @@ export class OtelCollectorSidecar {
logGroupName: `${logGroupPrefix}/otel-collector`
});
const otelCollectorContainer = taskDefinition.addContainer("OtelCollectorContainer", {
image: ContainerImage.fromDockerImageAsset(new DockerImageAsset(taskDefinition.stack, "OtelCollectorImage", {
directory: join(__dirname, "../../../../../", "TrafficCapture/dockerSolution/src/main/docker/otelCollector")
})),
image: makeLocalAssetContainerImage(taskDefinition.stack, "migrations/otel_collector:latest"),
containerName: "otel-collector",
command: ["--config=/etc/otel-config-aws.yaml"],
portMappings: [otelCollectorPort, otelCollectorHealthcheckPort],
Expand Down

0 comments on commit 1c377a2

Please sign in to comment.