-
Notifications
You must be signed in to change notification settings - Fork 4.5k
(aws-events): HttpParameter.fromString misses isValueSecret attribute #21855
Copy link
Copy link
Closed
Labels
@aws-cdk/aws-eventsRelated to CloudWatch EventsRelated to CloudWatch EventsbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortin-progressThis issue is being actively worked on.This issue is being actively worked on.p2
Description
Describe the bug
While creating a aws events connection for example to push messages to a slack channel one has to set additional header values for the api calls.
In this example
const connection = new Connection(this, "connection", {
authorization: Authorization.apiKey( "authorization", secret.secretValue),
headerParameters: {
"Content-Type": HttpParameter.fromString("application/json"),
},
});an additional header Content-Type is added.
This does not work as expected.
Expected Behavior
Api calls using this connection have the header value present.
Current Behavior
The api calls do not include the header value.
The connection headers are marked as secret
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-connection-parameter.html
{
"ConnectionArn": "arn:aws:events:eu-west-1:XXXXXXX:connection/SomeConnection/0848ec46-413a-4d40-8834-XXXXXX",
"Name": "SomeConnection",
"ConnectionState": "AUTHORIZED",
"AuthorizationType": "API_KEY",
"SecretArn": "arn:aws:secretsmanager:eu-west-1:XXXXXXX:secret:events!connection/SomeSecret/1e74cbb0-dfc6-4b77-a49f-b204e6b74a46-XXXXXX",
"AuthParameters": {
"ApiKeyAuthParameters": {
"ApiKeyName": "authorization"
},
"InvocationHttpParameters": {
"HeaderParameters": [
{
"Key": "Content-Type",
"IsValueSecret": true
}
]
}
},
"CreationTime": "2022-08-29T16:57:35+02:00",
"LastModifiedTime": "2022-08-29T16:57:35+02:00",
"LastAuthorizedTime": "2022-08-29T16:57:35+02:00"
}Reproduction Steps
const connection = new Connection(this, "connection", {
authorization: Authorization.apiKey( "authorization", secret.secretValue),
headerParameters: {
"Content-Type": HttpParameter.fromString("application/json"),
},
});Possible Solution
const connection = new Connection(this, "connection", {
authorization: Authorization.apiKey( "authorization", secret.secretValue),
headerParameters: {
"Content-Type": {
// begin workaround
_render: () => {
return {
key: "Content-Type",
value: "application/json",
isValueSecret: false,
};
},
// end workaround
},
},
});Additional Information/Context
The HttpParameter from the aws-events package need to set isValueSecret: false
I will provide a PR myself.
CDK CLI Version
2.33.0 (build 859272d)
Framework Version
No response
Node.js Version
v16.14.0
OS
macos
Language
Typescript
Language Version
4.7.4
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-eventsRelated to CloudWatch EventsRelated to CloudWatch EventsbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortin-progressThis issue is being actively worked on.This issue is being actively worked on.p2