aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.5k stars 3.84k forks source link

aws_apigateway: obtain DomainName instead of IDomainName #28203

Open stefdaems opened 9 months ago

stefdaems commented 9 months ago

Describe the feature

Make it possible to retrieve the DomainName from the arn. Now it is only possible on retrieving the IDomainName, not the DomainName.

Use Case

With apigateway v1 it is possible to add Api Mappings to a certain stage in your API gateway. This feature is recently added and ported from apigateway v2.

The addApiMapping method can be used on the DomainName. When the DomainName is created in another stack, and shared inside a project, we only can get the IDomainName and not the DomainName. The IDomainName is retrieved using the following code:

const domainName = DomainName.fromDomainNameAttributes(this, "DomainName", { domainName: xxx, domainNameAliasHostedZoneId: yyy, domainNameAliasTarget: zzz, });

As this is returning an IDomainName I can not perform addApiMapping on it.

Proposed Solution

It would be nice if we could do

const domainName: DomainName = DomainName.fromAttributes(this, "att", { domainNameArn: "arn:xxx:xxx:xxx" })

Other Information

No response

Acknowledgements

CDK version used

2.111.0

Environment details (OS name and version, etc.)

Mac

stefdaems commented 9 months ago

I'm getting it to work when using the apigatewayv2.CfnApiMapping like

new apigatewayv2.CfnApiMapping(this, ApiMapping, { apiId: theApiId, domainName: theDomainName, stage: theStageName, apiMappingKey: theMultilevelBasePath, });