Skip to content

Commit

Permalink
feat(aws-ec2): can now use PrefixList in ingress rules (#1360)
Browse files Browse the repository at this point in the history
Expose the newly-added capability of using PrefixLists
as peers for Security Group ingress rules.
  • Loading branch information
rix0rrr authored and RomainMuller committed Dec 14, 2018
1 parent 9ebe28b commit c3cfcd5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-ec2/lib/security-group-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class AnyIPv6 extends CidrIPv6 {
* https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-endpoints.html
*/
export class PrefixList implements ISecurityGroupRule, IConnectable {
public readonly canInlineRule = true;
public readonly canInlineRule = false;
public readonly connections: Connections = new Connections({ securityGroupRule: this });
public readonly uniqueId: string;

Expand All @@ -114,7 +114,7 @@ export class PrefixList implements ISecurityGroupRule, IConnectable {
}

public toIngressRuleJSON(): any {
throw new Error('Prefix lists can only be used for egress rules');
return { sourcePrefixListId: this.prefixListId };
}

public toEgressRuleJSON(): any {
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-ec2/test/test.security-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export = {
for (const peer of peers) {
for (const port of ports) {
sg.connections.allowTo(peer, port);
sg.connections.allowFrom(peer, port);
}
}

Expand Down

0 comments on commit c3cfcd5

Please sign in to comment.