fix(aws-route53-targets): add support for custom cname_prefix urls in elastic beanstalk environment endpoint target#18804
fix(aws-route53-targets): add support for custom cname_prefix urls in elastic beanstalk environment endpoint target#18804mergify[bot] merged 8 commits intoaws:masterfrom nicfix:aws-route53-elasticbeanstalk-target-urls-fix
Conversation
…k when configuring the custom_prefix attribute. Added a test to verify the new urls support.
….com:nicfix/aws-cdk into aws-route53-elasticbeanstalk-target-urls-fix
|
Hi @comcalvi, any chance to review this PR? |
|
@nicfix Thanks for the PR submission! I'll get to this ASAP, no later than next week. |
|
Thanks a lot @comcalvi ! |
|
Hi @comcalvi, |
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
May this PR be merged to cdk v2 too? because it has the same issue |
… elastic beanstalk environment endpoint target (aws#18804) This PR fixes the extraction of the region name from a Elastic Beanstalk Environment URL generated with a custom CNAME_PREFIX. The code is backward compatible with the regular URL # Motivation ElasticBeanstalkEnvironmentEndpointTarget is used to create an alias target for ElasticBeanstalk Environments that are already created and published for a certain region. When creating an ElasticBeanstalk Environment is possible to configure a `cname_prefix` in order to have a "deterministic" url for the generated environment. Normally the generated url looks like `mybeanstalkenvironment.xyz.eu-west-1.elasticbeanstalk.com`, however when the `cname_prefix` is specified the url loses the randomly generated hash and looks like `mycnameprefix.eu-west-1.elasticbeanstalk.com`. In the custom `cname_prefix` scenario the `ElasticBeanstalkEnvironmentEndpointTarget` class fails with the following error: ``` jsii.errors.JSIIError: Elastic Beanstalk environment target is not supported for the "elasticbeanstalk" region. ``` I mentioned this problem also [here](aws#17992 (comment)), sorry for the double comment. This PR does not fix the original problem of that issue thread. # How to reproduce Consider this scenario: ``` # app1.py # EB Enviroment enviroment = elasticbeanstalk.CfnEnvironment(self, 'Enviroment', environment_name='MySampleEnviroment', application_name=application.application_name or application_name, solution_stack_name=SOLUTION_STACK_NAME, option_settings=self.get_option_setting_properties(), version_label=app_version_props.ref, cname_prefix='myapp' ) ``` This generates an elastic beanstalk environment with url `myapp.eu-west-1.elasticbeanstalk.com` (supposing one it's deploying in eu-west-1). Then a following cdk app tries to create a DNS record for it ``` # app2.py route53.ARecord(self, f'{construct_label}AliasRecord', target=route53.RecordTarget.from_alias( targets.ElasticBeanstalkEnvironmentEndpointTarget( 'myapp.eu-west-1.elasticbeanstalk.com', ), ), zone=domain_configuration.hosted_zone, ) ``` At this point the command cdk diff returns the following error: ``` jsii.errors.JSIIError: Elastic Beanstalk environment target is not supported for the "elasticbeanstalk" region. ``` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This PR fixes the extraction of the region name from a Elastic Beanstalk Environment URL generated with a custom CNAME_PREFIX.
The code is backward compatible with the regular URL
Motivation
ElasticBeanstalkEnvironmentEndpointTarget is used to create an alias target for ElasticBeanstalk Environments that are already created and published for a certain region.
When creating an ElasticBeanstalk Environment is possible to configure a
cname_prefixin order to have a "deterministic" url for the generated environment.Normally the generated url looks like
mybeanstalkenvironment.xyz.eu-west-1.elasticbeanstalk.com, however when thecname_prefixis specified the url loses the randomly generated hash and looks likemycnameprefix.eu-west-1.elasticbeanstalk.com.In the custom
cname_prefixscenario theElasticBeanstalkEnvironmentEndpointTargetclass fails with the following error:I mentioned this problem also here, sorry for the double comment. This PR does not fix the original problem of that issue thread.
How to reproduce
Consider this scenario:
This generates an elastic beanstalk environment with url
myapp.eu-west-1.elasticbeanstalk.com(supposing one it's deploying in eu-west-1).Then a following cdk app tries to create a DNS record for it
At this point the command cdk diff returns the following error:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license