Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(ECS.LogsDrivers): Resolution error when using ecs.LogDrivers.firelens secretOptions #28279

Closed
lockenj opened this issue Dec 6, 2023 · 5 comments
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@lockenj
Copy link

lockenj commented Dec 6, 2023

Describe the bug

I get a Resolution Error when trying to synthesize `

Expected Behavior

If I retrieve my Datadog API Key secret and attempt to use secretOptions like the simplified snippet below I get Resolution error: Trying to resolve a non-data object. Only token are supported for lazy evaluation.

const dataDogApiKeySecret = secretsmanager.Secret.fromSecretNameV2(this, 'DataDogApiKeySecret', this.#_dataDogApiKeySecretName);
...
this.#_taskDefinition.addContainer('Server', {
      ...
      logging: ecs.LogDrivers.firelens({
        options: {
          ...
          secretOptions: {
            apikey: ecs.Secret.fromSecretsManager(dataDogApiKeySecret)
          }
        }
      })
      ...deltaServerContainer
});

Current Behavior

Error: Resolution error: Resolution error: Resolution error: Trying to resolve a non-data object. Only token are supported for lazy evaluation. Path: /Resources/${Token[DeltaServerStack.DeltaServer.TaskDefinition.Resource.LogicalID.498]}/Properties/containerDefinitions/2/logConfiguration/options/secretOptions/apikey/grantRead. Object: grantee=>secret.grantRead(grantee).

Reproduction Steps

See snippet above... Just running cdk synth or cdk deploy gives the error

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.114.1

Framework Version

No response

Node.js Version

v20.7.0

OS

MAC 13.4.1

Language

TypeScript

Language Version

No response

Other information

No response

@lockenj lockenj added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 6, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Dec 6, 2023
@pahud
Copy link
Contributor

pahud commented Dec 7, 2023

I just tried the code below and I can successfully synth and deploy with no errors.

export class Demo extends DemoStack {
	constructor(scope: Construct, id: string, props: StackProps) {
		super(scope, id, props);

		const task = new ecs.Ec2TaskDefinition(this, 'Task');
		const dataDogApiKeySecret = secretsmanager.Secret.fromSecretNameV2(this, 'DataDogApiKeySecret', 'dummyName');
		task.addContainer('Server', {
			image: ecs.ContainerImage.fromRegistry('nginx'),
			memoryLimitMiB: 512,
			cpu: 1,
			logging: ecs.LogDrivers.firelens({
				options: {
					Name: 'firehose',
					region: 'us-east-1',
					delivery_stream: 'my-stream',
				},
				secretOptions: {
					apikey: ecs.Secret.fromSecretsManager(dataDogApiKeySecret)
				}
			})
		});
	}	
}

As I can't see your full code, I am not sure if it's a bug but it works to me with the code above. Can you simplify your code and see if it works with the latest cdk release?

@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Dec 7, 2023
Copy link

github-actions bot commented Dec 9, 2023

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Dec 9, 2023
@lockenj
Copy link
Author

lockenj commented Dec 9, 2023

I was playing with simplifying things yesterday. Once I narrow it down to exactly what's causing the issue I will share a snippet. Thanks for your help on this!

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Dec 9, 2023
@lockenj
Copy link
Author

lockenj commented Dec 11, 2023

This was absolutely my bad. I had secretOptions property within the options object... DOH!

If you do that (like the snippet below) you get that really confusing Resolution Error.

const task = new ecs.Ec2TaskDefinition(this, 'Task');
        const dataDogApiKeySecret = secretsmanager.Secret.fromSecretNameV2(this, 'DataDogApiKeySecret', 'dummyName');
        task.addContainer('Server', {
            image: ecs.ContainerImage.fromRegistry('nginx'),
            memoryLimitMiB: 512,
            cpu: 1,
            logging: ecs.LogDrivers.firelens({
                options: {
                    Name: 'firehose',
                    region: 'us-east-1',
                    delivery_stream: 'my-stream',
                    secretOptions: {
                        apikey: ecs.Secret.fromSecretsManager(dataDogApiKeySecret)
                    }
                },
            })
        });
        ```

@lockenj lockenj closed this as completed Dec 11, 2023
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

2 participants