aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.61k stars 3.91k forks source link

(aws-iotevents): golang: export _bind so that L2 constructs can be written in Go #25004

Open karl-dau opened 1 year ago

karl-dau commented 1 year ago

Describe the feature

I want to write my own IAction in Go (for SNS publishing), but I cannot seem to satisfy the correct interface.

Looking at the definition:

export interface IAction {
  /**
   * Returns the AWS IoT Events action specification.
   * @internal
   */
  _bind(scope: Construct, options: ActionBindOptions): ActionConfig;
}

_bind is not exported so it is not part of the generated Go IAction.

the aws-iot Actions used to have Bind exported and I could write my own actions before CDK officially supported the DynamoDBv2 action.

Passing in a Go a struct with method:

func (action *IoTEventSNSAction) _Bind(scope constructs.Construct, options *iotevents.ActionBindOptions) *iotevents.ActionConfig {

results in panic: action._bind is not a function.

Alternatively, is there another way to achieve this?

Use Case

I have no way to extend the functionality here, except first write a Typescript class.

Proposed Solution

No response

Other Information

No response

Acknowledgements

CDK version used

2.73.0

Environment details (OS name and version, etc.)

macOS 13.3

pahud commented 1 year ago

I believe the Bind method is supposed to be internal and not to be exported.

What is your use case? Can you share more about your code?

karl-dau commented 1 year ago

@pahud I am trying to add the SNS Action (which is not currently implemented for the L2 construct) using my own Go code. I also cannot downcast the L2 DetectorModel construct because DetectorModel.(CfnDetectorModel).DetectorModelDefinition().(CfnDetectorModel.DetectorModelDefinitionProperty) does not work, seeing as the jsiiProxy object can't be type asserted to DetectorModelDefinitionProperty.

Any other ideas?