Skip to content

Commit

Permalink
Remove an awkward prop type option
Browse files Browse the repository at this point in the history
  • Loading branch information
plumdog committed Dec 21, 2023
1 parent e458c1b commit a93f0bf
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions ec2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Construct } from 'constructs';

import * as cdk from 'aws-cdk-lib';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import type * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';

export interface DatadogEcsLogsProps {
/**
Expand Down Expand Up @@ -32,14 +31,8 @@ export interface DatadogEcsDaemonServiceProps {
readonly ecsCluster: ecs.Cluster;
/**
* The secret containing the Datadog API key
*
* @remarks
* Pass an ecs.Secret for full control over the source of
* this. Can pass an ISecret for backwards compatibility, though
* this must be a secret storing a single value, not key-value
* pairs.
*/
readonly datadogApiKeySecret: ecs.Secret | secretsmanager.ISecret;
readonly datadogApiKeySecret: ecs.Secret;
/**
* The Datadog site to send data to
*
Expand Down Expand Up @@ -91,14 +84,6 @@ export interface DatadogEcsDaemonServiceProps {
readonly disableHealthcheck?: boolean;
}

// Type-guard for ecs.Secret
const isEcsSecret = (secret: secretsmanager.ISecret | ecs.Secret): secret is ecs.Secret => {
if (secret.hasOwnProperty('secretArn')) {
return false;
}
return true;
};

/**
* Deploys the Datadog agent as a daemon service to an ECS cluster.
*
Expand Down Expand Up @@ -143,7 +128,7 @@ export class DatadogEcsDaemonService extends Construct {
: {}),
},
secrets: {
DD_API_KEY: isEcsSecret(props.datadogApiKeySecret) ? props.datadogApiKeySecret : ecs.Secret.fromSecretsManager(props.datadogApiKeySecret),
DD_API_KEY: props.datadogApiKeySecret,
},
...(props.disableHealthcheck
? {}
Expand Down

0 comments on commit a93f0bf

Please sign in to comment.