-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(events): additional plaintext header are not set on eventbridge connection #21857
fix(events): additional plaintext header are not set on eventbridge connection #21857
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure that your PR title confirms to the conventional commit standard (fix, feat, chore) and that it is written in a style that will reflect correctly in the change log (See Contributing Guide, Pull Requests).
Additionally, please make sure that your PR body describes the problem the PR is solving, and the design approach and alternatives considered. Explain why the PR solves the problem. A link to an issue is helpful, but does not replace an explanation of your thought process.
Lastly, we need an integration test for this change.
@@ -199,6 +199,7 @@ export abstract class HttpParameter { | |||
return { | |||
key: name, | |||
value, | |||
isValueSecret: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why will this always be false? This PR needs context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this value needs to be set to false to indicate the provided value is not secret. Since this is the render method from the HttpParameter.fromString()
the value is always treated as not secret. If you like to provide a secret value you have to use the HttpParameter.fromSecret()
method.
The default value for isValueSecret
seams to be true
if not provided. See the updated PR description or linked issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hit the wrong button and didn't put this into request changes.
Pull request has been modified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting this back in request changes since there are still some things to be addressed.
Pull request has been modified.
bd41798
to
cefb64d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs merge conflicts resolved.
6352580
to
af59ed6
Compare
Pull request has been modified.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Fixes: #21855
While creating a Eventbridge connection to make api calls to an external api one sometimes have to add additional header parameters like
Content-Type = application/json
These additional headers can be either be a secret value or a plaintext value specified at deploy time.
The connection class provides a HttpParameter class that alows you to set a static/unsecure/plaintext value for a header key
This should lead to api calls made with the connection have a Header present with key/value
"Content-Type": "application/json"
,The actual behavior was prior to this Fix that the header wasn't present in the api calls made with this connection.
While debugging the issue I used the following aws cli commands to check what has been deployed by cdk/cloudformation
aws events describe-connection --name <name-of-the-connection>
which result was similair to this
Which indicates that the header value is not set because it is treated as secret value and needs to be provided by the referenced secret.
Then i checked the Cloudformation spec
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-connection-parameter.html
There it is indicated that there is the property
isValueSecret
which indicates if the value is a secret or not.The next step was to check why cdk generates a template that doesn't work and thereby checked the HttpParameter class.
This class is responsible for generating the
AWS::Events::Connection Parameter
properties.I noticed that only the
HttpParameter.fromSecret()
sets theisValueSecret
flag.But it seems to be the case that for this property the default value is true by cloudformation, so omiting this attribute in the _render function results to
isValueSecret: true
at deploy time.After that i explicity set the value to false for the case the user specifies a plaintext value throught the
HttpParameter.fromString()
method.To make sure the correct values are deployed by cloudformation I added a integration test including an assertion that the deployed connection has the correct isValueSecret flag set and the value for the header is set.
All Submissions:
Adding new Unconventional Dependencies:
New Features
yarn integ
to deploy the infrastructure and generate the snapshot (i.e.yarn integ
without--dry-run
)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license