question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Go: AppRunner - failed mapping between fields and types

See original GitHub issue

❓ General Issue

The generated Go code doesn’t connect fields with the correct data types.

In the example below, the CfnServiceProps struct has a SourceConfiguration field, but this field is of type interface{} instead of the generated typeCfnService_SourceConfigurationProperty.

type CfnService_SourceConfigurationProperty struct {
	// `CfnService.SourceConfigurationProperty.AuthenticationConfiguration`.
	AuthenticationConfiguration interface{} `json:"authenticationConfiguration"`
	// `CfnService.SourceConfigurationProperty.AutoDeploymentsEnabled`.
	AutoDeploymentsEnabled interface{} `json:"autoDeploymentsEnabled"`
	// `CfnService.SourceConfigurationProperty.CodeRepository`.
	CodeRepository interface{} `json:"codeRepository"`
	// `CfnService.SourceConfigurationProperty.ImageRepository`.
	ImageRepository interface{} `json:"imageRepository"`
}

// Properties for defining a `AWS::AppRunner::Service`.
type CfnServiceProps struct {
	// `AWS::AppRunner::Service.SourceConfiguration`.
	SourceConfiguration interface{} `json:"sourceConfiguration"`
	// `AWS::AppRunner::Service.AutoScalingConfigurationArn`.
	AutoScalingConfigurationArn *string `json:"autoScalingConfigurationArn"`
	// `AWS::AppRunner::Service.EncryptionConfiguration`.
	EncryptionConfiguration interface{} `json:"encryptionConfiguration"`
	// `AWS::AppRunner::Service.HealthCheckConfiguration`.
	HealthCheckConfiguration interface{} `json:"healthCheckConfiguration"`
	// `AWS::AppRunner::Service.InstanceConfiguration`.
	InstanceConfiguration interface{} `json:"instanceConfiguration"`
	// `AWS::AppRunner::Service.ServiceName`.
	ServiceName *string `json:"serviceName"`
	// `AWS::AppRunner::Service.Tags`.
	Tags *[]*awscdk.CfnTag `json:"tags"`
}

This led me to (incorrectly) guessing at the config:

	awsapprunner.NewCfnService(stack, jsii.String("AppRunner"), &awsapprunner.CfnServiceProps{
		SourceConfiguration: &awsapprunner.CfnService_SourceConfigurationProperty{
			ImageRepository: &awsapprunner.CfnService_ImageRepositoryProperty{
				ImageIdentifier: image.ImageUri(),
				ImageConfiguration: &awsapprunner.CfnService_ImageConfigurationProperty{
					Port: jsii.String("80"),
				},
				ImageRepositoryType: jsii.String("ECR"),
			},
		},
	})

This resulted in incorrect SourceConfiguration and unexpected errors.

  AppRunner:
    Type: AWS::AppRunner::Service
    Properties:
      SourceConfiguration: {}
    Metadata:
      aws:cdk:path: CdkGoAppRunnerStack/AppRunner

I documented the correct way here: https://adrianhesketh.com/2021/06/14/go-cdk-app-runner/

Environment

  • CDK CLI Version: 1.108.1
  • Module Version: github.com/aws/aws-cdk-go/awscdk v1.108.0-devpreview
  • Node.js Version: v14.15.5
  • OS: MacOS
  • Language (Version): Go

Other information

Suggest that:

  • CfnService_SourceConfigurationProperty is renamed to remove the “CfnService_” prefix unless it’s required.
  • CfnService_SourceConfigurationProperty is renamed to remove the “Property” prefix. Go structs don’t have properties, they have fields.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
peterwoodworthcommented, Jul 13, 2021

Marking this as a feature request. @MrArnoldPalmer should be able to give you a response soon

0reactions
github-actions[bot]commented, Dec 14, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

apprunner - Amazon Web Services - Go SDK
App Runner is an application service that provides a fast, simple, and cost-effective way to go directly from an existing container image or...
Read more >
apprunner - Go Packages
App Runner App Runner is an application service that provides a fast, simple, and cost-effective way to go directly from an existing container...
Read more >
Running a Go app on AWS App Runner with CDK
At the time of writing, the Go SDK has a problem with its type definitions for App Runner where the sourceConfiguration field doesn't...
Read more >
AWS App Runner health check fails even though appropriate ...
yet I get this from App Runner: 10-08-2022 10:07:57 PM [AppRunner] ...
Read more >
opentelemetry-collector-contrib/CHANGELOG.md at main
In logproto.pb.go I had to remove few types Query[Request|Response] and ... datadogexporter : Use minimum and maximum fields from delta OTLP Histograms and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found