goformation icon indicating copy to clipboard operation
goformation copied to clipboard

Fix if implementation

Open xrn opened this issue 2 years ago • 3 comments

Issue #, if available:

https://github.com/awslabs/goformation/issues/471

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

xrn avatar Jul 11 '22 13:07 xrn

@rubenfonseca any chance that you will take a look on this? (Previous implementation of If with

switch v := ifEqual.(type) {

was written by my team member as well and merged to master but seems that it can be simplified

xrn avatar Jul 15 '22 11:07 xrn

@rubenfonseca - unfortunately it won't be simple. I have my own fork of this repo where for some resources where I need to use parameter and then Intrinsics functions I can change type to string or interface{}. In this case I have to change

&apigateway.RestApi{
		Name: "test",
		Description: "test",
		EndpointConfiguration: cloudformation.If("PrivateApiGateway",
			apigateway.RestApi_EndpointConfiguration{
				Types: cloudformation.Strings("PRIVATE"),
				VpcEndpointIds: cloudformation.Strings(
					cloudformation.Ref("ExecuteApiEndpointId"),
				),
			},

apigateway.RestApi.EndpointConfiguration from apigateway.RestApi_EndpointConfiguration to interface{} to be able to accept this if result. But still current if implementation is incorrect with current version I will get

 ApiGateway:
    Properties:
      Name: "test"
      Description: "test"
      EndpointConfiguration: eyAiRm46OklmIiA6IFsgIlByaXZhdGVBcGlHYXRld2F5IiwgeyUhcSgqW11zdHJpbmc9JltQUklWQVRFXSkgJSFxKCpbXXN0cmluZz0mW2V5QWlVbVZtSWpvZ0lrVjRaV04xZEdWQmNHbEZibVJ3YjJsdWRFbGtJaUI5XSkgIiIgIiIgW10gbWFwW10gIiJ9LCB7JSFxKCpbXXN0cmluZz0mW0VER0VdKSAlIXEoKltdc3RyaW5nPTxuaWw+KSAiIiAiIiBbXSBtYXBbXSAiIn0gXSB9

After fix

ApiGateway:
    Properties:
      Name: "test"
      Description: "test"
      EndpointConfiguration:
        Fn::If:
        - PrivateApiGateway
        - Types:
          - PRIVATE
          VpcEndpointIds:
          - Ref: ExecuteApiEndpointId
        - Types:
          - EDGE

xrn avatar Jul 18 '22 07:07 xrn

Thanks! Please give me some time so I can write a test in order for us to merge this.

rubenfonseca avatar Jul 18 '22 09:07 rubenfonseca

Hi @rubenfonseca - any chance that you will take a look on this?

xrn avatar Aug 17 '22 06:08 xrn

Thanks @xrn, merging it

rubenfonseca avatar Aug 17 '22 14:08 rubenfonseca

:tada: This PR is included in version 6.7.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Aug 17 '22 14:08 github-actions[bot]