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

feat(apigatewayv2): introduce new interface for integration with sfn tasks and r53 targets #14202

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as apigv2 from '@aws-cdk/aws-apigatewayv2';
import * as route53 from '@aws-cdk/aws-route53';

/**
* Defines an API Gateway V2 domain name as the alias target.
*/
export class ApiGatewayv2Domain implements route53.IAliasRecordTarget {
constructor(private readonly domainName: apigv2.IDomainName) { }
constructor(private readonly domainName: ApiGateWayDomainName) { }

public bind(_record: route53.IRecordSet): route53.AliasRecordTargetConfig {
return {
Expand All @@ -14,3 +13,19 @@ export class ApiGatewayv2Domain implements route53.IAliasRecordTarget {
};
}
}

/**
* Represents an APIGatewayV2 DomainName
*/
export interface ApiGatewayDomainName {
/**
* The region-specific Amazon Route 53 Hosted Zone ID of the regional endpoint.
*/
readonly regionalHostedZoneId: string;

/**
* The domain name associated with the regional endpoint for this custom domain name.
*/
readonly regionalDomainName: string;

}
3 changes: 1 addition & 2 deletions packages/@aws-cdk/aws-route53-targets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"devDependencies": {
"@aws-cdk/assert": "0.0.0",
"@aws-cdk/aws-certificatemanager": "0.0.0",
"@aws-cdk/aws-apigatewayv2": "0.0.0",
"@aws-cdk/aws-lambda": "0.0.0",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
Expand All @@ -74,7 +75,6 @@
},
"dependencies": {
"@aws-cdk/aws-apigateway": "0.0.0",
"@aws-cdk/aws-apigatewayv2": "0.0.0",
"@aws-cdk/aws-cloudfront": "0.0.0",
"@aws-cdk/aws-cognito": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
Expand All @@ -91,7 +91,6 @@
"homepage": "https://github.com/aws/aws-cdk",
"peerDependencies": {
"@aws-cdk/aws-apigateway": "0.0.0",
"@aws-cdk/aws-apigatewayv2": "0.0.0",
"@aws-cdk/aws-cloudfront": "0.0.0",
"@aws-cdk/aws-cognito": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import * as apigatewayv2 from '@aws-cdk/aws-apigatewayv2';
import * as iam from '@aws-cdk/aws-iam';
import * as sfn from '@aws-cdk/aws-stepfunctions';
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';
import { Construct, IConstruct } from 'constructs';
import { CallApiGatewayEndpointBase } from './base';
import { CallApiGatewayEndpointBaseProps } from './base-types';

/**
* An APIGateWayV2 Http API resource representation
*/
export interface IApiGatewayV2HttpApi extends IConstruct {
/**
* The identifier of this API Gateway HTTP API.
*/
readonly apiId: string;
}

/**
* Properties for calling an HTTP API Endpoint
*/
export interface CallApiGatewayHttpApiEndpointProps extends CallApiGatewayEndpointBaseProps {
/**
* API to call
*/
readonly api: apigatewayv2.IHttpApi;
readonly api: IApiGatewayV2HttpApi;
Comment on lines -16 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just make this -

readonly apiId: string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Because of the way it is used in the consumer. The consumer code requires the apigw containing Construct in order to get the defining Stack to get its region:
const apiStack = cdk.Stack.of(this.props.api);
return `${this.props.api.apiId}.execute-api.${apiStack.region}.${apiStack.urlSuffix}`;

The way to express it with an interface is to have it extends IConstruct which will enforce the requirements of a scope.

Since we decided to merge this change to master (in the chat), keeping the interface has the advantage of not breaking typescript users.


/**
* Name of the stage where the API is deployed to in API Gateway
Expand Down
6 changes: 2 additions & 4 deletions packages/@aws-cdk/aws-stepfunctions-tasks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@
"@aws-cdk/assert": "0.0.0",
"@aws-cdk/aws-s3-assets": "0.0.0",
"@aws-cdk/aws-sns-subscriptions": "0.0.0",
"@aws-cdk/aws-apigatewayv2": "0.0.0",
"@aws-cdk/aws-apigatewayv2-integrations": "0.0.0",
"cdk-build-tools": "0.0.0",
"cdk-integ-tools": "0.0.0",
"jest": "^26.6.3",
"pkglint": "0.0.0"
},
"dependencies": {
"@aws-cdk/aws-apigateway": "0.0.0",
"@aws-cdk/aws-apigatewayv2": "0.0.0",
"@aws-cdk/aws-apigatewayv2-integrations": "0.0.0",
"@aws-cdk/aws-batch": "0.0.0",
"@aws-cdk/aws-cloudwatch": "0.0.0",
"@aws-cdk/aws-codebuild": "0.0.0",
Expand All @@ -100,8 +100,6 @@
"homepage": "https://github.com/aws/aws-cdk",
"peerDependencies": {
"@aws-cdk/aws-apigateway": "0.0.0",
"@aws-cdk/aws-apigatewayv2": "0.0.0",
"@aws-cdk/aws-apigatewayv2-integrations": "0.0.0",
"@aws-cdk/aws-batch": "0.0.0",
"@aws-cdk/aws-cloudwatch": "0.0.0",
"@aws-cdk/aws-codebuild": "0.0.0",
Expand Down