Skip to content

Go: demonstrate how to use CfnParameter string values #849

Open
@jpmcb

Description

@jpmcb

Describe the feature

Let's say that I have this function

func CreateCluster(stack constructs.Construct, instanceType awscdk.CfnParameter) eks.Cluster {
        cluster := awseks.NewCluster(stack, jsii.String("my-cluster"), &awseks.ClusterProps{ ... })

	cluster.AddNodegroupCapacity(jsii.String("my-nodegroup"), &eks.NodegroupOptions{
		InstanceTypes: &[]ec2.InstanceType{
			ec2.NewInstanceType(instanceType.ValueAsString()),
                }
        })
}

where I want to pass in a cdk parameter.

Doing the above breaks in weird ways:

panic: Error: Malformed instance type identifier

goroutine 1 [running]:

Doing a

fmt.Printf("Instance type: %v\n", instanceType.ValueAsString())

shows that the value at buildtime is actually just a node as a string:

Instance type: ${Token[TOKEN.652]}

What am I missing here? I expected ValueAsString() to just work ™️

Use Case

Having an example of using ValueAsString() would be really useful for passing parameters to Go cdk stacks.

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Language

Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.language/goRelated to Go examplesp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions