Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apprunner-alpha: VpcIngressConnection uses incompatible IService instead of Service in JAVA #32745

Closed
1 task
muhamadto opened this issue Jan 6, 2025 · 3 comments · Fixed by #32771
Closed
1 task
Labels
@aws-cdk/aws-apprunner Related to the apprunner package bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@muhamadto
Copy link

muhamadto commented Jan 6, 2025

Describe the bug

The example provided in VpcIngressConnection does not work as the service method accepts software.amazon.awscdk.services.apprunner.alpha.IService. the service created in line 7 is of type software.amazon.awscdk.services.apprunner.alpha.Service which does not inherit from IService leading to a compilation error in the second last line when using VpcIngressConnection#service(IService)

InterfaceVpcEndpoint interfaceVpcEndpoint = InterfaceVpcEndpoint.Builder.create(this, "MyVpcEndpoint")
        .vpc(vpc)
        .service(InterfaceVpcEndpointAwsService.APP_RUNNER_REQUESTS)
        .privateDnsEnabled(false)
        .build();

Service service = Service.Builder.create(this, "Service")
        .source(Source.fromEcrPublic(EcrPublicProps.builder()
                .imageConfiguration(ImageConfiguration.builder()
                        .port(8000)
                        .build())
                .imageIdentifier("public.ecr.aws/aws-containers/hello-app-runner:latest")
                .build()))
        .isPubliclyAccessible(false)
        .build();

VpcIngressConnection.Builder.create(this, "VpcIngressConnection")
        .vpc(vpc)
        .interfaceVpcEndpoint(interfaceVpcEndpoint)
        .service(service).   // incompatible types
        .build();

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

VpcIngressConnection#service(Service) should not throw a compilation error when passing a service.

Current Behavior

A compilation error in the second last line when using VpcIngressConnection#service(IService) with the service created by Service.Builder#create()

Reproduction Steps

Just use the provided example in the documentation

Possible Solution

Either

  • MakeService inherit IService or
  • Change VpcIngressConnection#service(IService) to VpcIngressConnection#service(Service)

Additional Information/Context

No response

CDK CLI Version

2.174.0

Framework Version

No response

Node.js Version

v23.5.0

OS

Mac

Language

Java

Language Version

21

Other information

No response

@muhamadto muhamadto added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 6, 2025
@github-actions github-actions bot added the @aws-cdk/aws-apprunner Related to the apprunner package label Jan 6, 2025
@ashishdhingra ashishdhingra self-assigned this Jan 6, 2025
@ashishdhingra ashishdhingra added p2 investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Jan 6, 2025
@ashishdhingra
Copy link
Contributor

Appears to be a valid use case. Just for comparison, in aws-ec2 package, IVpc is implemented by VpcBase, which is in turn inherited by Vpc.

Unsure if we have any design guidelines for experimental constructs to follow certain pattern.

In customer's use case, the possible workaround could be to use Service.fromServiceName(this, "ServiceImported", service.getServiceName()) as demonstrated below:

package com.myorg;

import software.constructs.Construct;
import software.amazon.awscdk.Stack;
import software.amazon.awscdk.StackProps;
import software.amazon.awscdk.services.apprunner.alpha.EcrPublicProps;
import software.amazon.awscdk.services.apprunner.alpha.ImageConfiguration;
import software.amazon.awscdk.services.apprunner.alpha.Service;
import software.amazon.awscdk.services.apprunner.alpha.Source;
import software.amazon.awscdk.services.apprunner.alpha.VpcIngressConnection;
import software.amazon.awscdk.services.ec2.Vpc;
import software.amazon.awscdk.services.ec2.InterfaceVpcEndpoint;
import software.amazon.awscdk.services.ec2.InterfaceVpcEndpointAwsService;

public class CdktestjavaStack extends Stack {
    public CdktestjavaStack(final Construct scope, final String id) {
        this(scope, id, null);
    }

    public CdktestjavaStack(final Construct scope, final String id, final StackProps props) {
        super(scope, id, props);

        Vpc vpc = Vpc.Builder.create(this, "testVpc").build();

        InterfaceVpcEndpoint interfaceVpcEndpoint = InterfaceVpcEndpoint.Builder.create(this, "MyVpcEndpoint")
        .vpc(vpc)
        .service(InterfaceVpcEndpointAwsService.APP_RUNNER_REQUESTS)
        .privateDnsEnabled(false)
        .build();

        Service service = Service.Builder.create(this, "Service")
                            .serviceName("MyService")
                            .source(Source.fromEcrPublic(EcrPublicProps.builder()
                                    .imageConfiguration(ImageConfiguration.builder()
                                            .port(8000)
                                            .build())
                                    .imageIdentifier("public.ecr.aws/aws-containers/hello-app-runner:latest")
                                    .build()))
                            .isPubliclyAccessible(false)
                            .build();

        VpcIngressConnection.Builder.create(this, "VpcIngressConnection")
            .vpc(vpc)
            .interfaceVpcEndpoint(interfaceVpcEndpoint)
            .service(Service.fromServiceName(this, "ServiceImported", service.getServiceName()))
            .build();
    }
}

@ashishdhingra ashishdhingra added effort/small Small work item – less than a day of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Jan 6, 2025
@ashishdhingra ashishdhingra removed their assignment Jan 6, 2025
@mergify mergify bot closed this as completed in #32771 Jan 7, 2025
@mergify mergify bot closed this as completed in 3d56efa Jan 7, 2025
Copy link

github-actions bot commented Jan 7, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

1 similar comment
Copy link

github-actions bot commented Jan 7, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-apprunner Related to the apprunner package bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants