-
Notifications
You must be signed in to change notification settings - Fork 4k
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(ecs): vpc link for api gatway and load balanced services #1541
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import elbv2 = require('@aws-cdk/aws-elasticloadbalancingv2'); | ||
import cdk = require('@aws-cdk/cdk'); | ||
import { CfnVpcLink } from './apigateway.generated'; | ||
|
||
/** | ||
* Properties for a VpcLink | ||
*/ | ||
export interface VpcLinkProps { | ||
/** | ||
* The name used to label and identify the VPC link. | ||
* @default automatically generated name | ||
*/ | ||
name?: string; | ||
|
||
/** | ||
* The description of the VPC link. | ||
* @default no description | ||
*/ | ||
description?: string; | ||
|
||
/** | ||
* The network load balancers of the VPC targeted by the VPC link. | ||
* The network load balancers must be owned by the same AWS account of the API owner. | ||
*/ | ||
targets: elbv2.INetworkLoadBalancer[]; | ||
} | ||
|
||
/** | ||
* Define a new VPC Link | ||
* Specifies an API Gateway VPC link for a RestApi to access resources in an Amazon Virtual Private Cloud (VPC). | ||
*/ | ||
export class VpcLink extends cdk.Construct { | ||
/** | ||
* Physical ID of the VpcLink resource | ||
*/ | ||
public readonly vpcLinkId: string; | ||
|
||
constructor(scope: cdk.Construct, id: string, props: VpcLinkProps) { | ||
super(scope, id); | ||
|
||
const cfnResource = new CfnVpcLink(this, 'Resource', { | ||
name: props.name || this.node.uniqueId, | ||
description: props.description, | ||
targetArns: props.targets.map(nlb => nlb.loadBalancerArn) | ||
}); | ||
|
||
this.vpcLinkId = cfnResource.vpcLinkId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { expect, haveResourceLike } from '@aws-cdk/assert'; | ||
import ec2 = require('@aws-cdk/aws-ec2'); | ||
import elbv2 = require('@aws-cdk/aws-elasticloadbalancingv2'); | ||
import cdk = require('@aws-cdk/cdk'); | ||
import { Test } from 'nodeunit'; | ||
import apigateway = require('../lib'); | ||
|
||
export = { | ||
'default setup'(test: Test) { | ||
// GIVEN | ||
const stack = new cdk.Stack(); | ||
const vpc = new ec2.VpcNetwork(stack, 'VPC'); | ||
const nlb = new elbv2.NetworkLoadBalancer(stack, 'NLB', { | ||
vpc | ||
}); | ||
|
||
// WHEN | ||
new apigateway.VpcLink(stack, 'VpcLink', { | ||
name: 'MyLink', | ||
targets: [nlb] | ||
}); | ||
|
||
// THEN | ||
expect(stack).to(haveResourceLike('AWS::ApiGateway::VpcLink', { | ||
Name: "MyLink", | ||
TargetArns: [ { Ref: "NLB55158F82" } ] | ||
})); | ||
|
||
test.done(); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if connectiontype === internet and a vpcLink is supplied. Is that ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs for ConnectionId state:
I took that to mean that it would just be ignored. Probably best to throw an error though to alert the user, since that's probably not what they wanted to happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I was getting at. Thanks.