Skip to content

(aws-events): HttpParameter.fromString misses isValueSecret attribute #21855

@RaphaelManke

Description

@RaphaelManke

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-eventsRelated to CloudWatch EventsbugThis issue is a bug.effort/smallSmall work item – less than a day of effortin-progressThis issue is being actively worked on.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions