Skip to content

Commit

Permalink
[New Template] vpc/vpc-endpoint - Generic VPC Endpoints (widdix#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwittig authored May 12, 2019
1 parent 6faff3c commit 6b31bd2
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 8 deletions.
26 changes: 20 additions & 6 deletions docs/vpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ There is no graphical tool available for Linux. You can establish an SSH connect
## Limitations
* Only one EC2 instance is managed by the ASG. In case of an outage the instance will be replaced within 5 minutes.

# VPC Endpoint to S3
This template describes a VPC endpoint to securely route traffic within a VPC for private instances to access S3 without the need of a NAT Gateway, NAT instance, or public internet. Refer to [AWS VPC endpoint](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-endpoints.html) documentation if this is necessary for your stack. By default, access to all S3 actions and buckets is allowed, but may be constrained with a policy document.
# Gateway Endpoint (S3)
This template describes a Gateway VPC endpoint to securely access S3 without the need of a NAT Gateway, NAT instance, or public internet. Refer to [AWS documentation](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-endpoints-s3.html) if this is necessary for your stack. By default, access to all S3 actions and buckets is allowed, but may be constrained with a policy document.

![Architecture](./img/vpc-endpoint-s3.png)
## Installation Guide
Expand All @@ -202,15 +202,14 @@ This template describes a VPC endpoint to securely route traffic within a VPC fo
1. Specify a name and all parameters for the stack.
1. Click **Next** to proceed with the next step of the wizard.
1. Click **Next** to skip the **Options** step of the wizard.
1. Check the **I acknowledge that this template might cause AWS CloudFormation to create IAM resources.** checkbox.
1. Click **Create** to start the creation of the stack.
1. Wait until the stack reaches the state **CREATE_COMPLETE**

## Dependencies
* `vpc/vpc-*azs.yaml` (**required**)

# VPC Endpoint to DynamoDB
This template describes a VPC endpoint to securely route traffic within a VPC for private instances to access DynamoDB without the need of a NAT Gateway, NAT instance, or public internet. Refer to [AWS VPC endpoint](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-endpoints.html) documentation if this is necessary for your stack. By default, access to all DynamoDB actions and tables is allowed, but may be constrained with a policy document.
# Gateway Endpoint (DynamoDB)
This template describes a Gateway VPC endpoint to securely access DynamoDB without the need of a NAT Gateway, NAT instance, or public internet. Refer to [AWS documentation](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-endpoints-ddb.html) if this is necessary for your stack. By default, access to all DynamoDB actions and tables is allowed, but may be constrained with a policy document.

## Installation Guide
1. This templates depends on one of our `vpc-*azs.yaml` templates. [![Launch Stack](./img/launch-stack.png)](https://console.aws.amazon.com/cloudformation/home#/stacks/create/review?templateURL=https://s3-eu-west-1.amazonaws.com/widdix-aws-cf-templates-releases-eu-west-1/__VERSION__/vpc/vpc-2azs.yaml&stackName=vpc)
Expand All @@ -219,7 +218,22 @@ This template describes a VPC endpoint to securely route traffic within a VPC fo
1. Specify a name and all parameters for the stack.
1. Click **Next** to proceed with the next step of the wizard.
1. Click **Next** to skip the **Options** step of the wizard.
1. Check the **I acknowledge that this template might cause AWS CloudFormation to create IAM resources.** checkbox.
1. Click **Create** to start the creation of the stack.
1. Wait until the stack reaches the state **CREATE_COMPLETE**

## Dependencies
* `vpc/vpc-*azs.yaml` (**required**)

# Interface Endpoint
This template describes a Interface VPC endpoint to securely access services without the need of a NAT Gateway, NAT instance, or public internet. Refer to [AWS documentation](https://docs.aws.amazon.com/vpc/latest/userguide/vpce-interface.html) if this is necessary for your stack.

## Installation Guide
1. This templates depends on one of our `vpc-*azs.yaml` templates. [![Launch Stack](./img/launch-stack.png)](https://console.aws.amazon.com/cloudformation/home#/stacks/create/review?templateURL=https://s3-eu-west-1.amazonaws.com/widdix-aws-cf-templates-releases-eu-west-1/__VERSION__/vpc/vpc-2azs.yaml&stackName=vpc)
1. [![Launch Stack](./img/launch-stack.png)](https://console.aws.amazon.com/cloudformation/home#/stacks/create/review?templateURL=https://s3-eu-west-1.amazonaws.com/widdix-aws-cf-templates-releases-eu-west-1/__VERSION__/vpc/vpc-endpoint.yaml&stackName=vpc-endpoint&param_ParentVPCStack=vpc)
1. Click **Next** to proceed with the next step of the wizard.
1. Specify a name and all parameters for the stack.
1. Click **Next** to proceed with the next step of the wizard.
1. Click **Next** to skip the **Options** step of the wizard.
1. Click **Create** to start the creation of the stack.
1. Wait until the stack reaches the state **CREATE_COMPLETE**

Expand Down
2 changes: 1 addition & 1 deletion vpc/vpc-endpoint-dynamodb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
AWSTemplateFormatVersion: '2010-09-09'
Description: 'VPC: Endpoint to DynamoDB for private subnets, a cloudonaut.io template'
Description: 'VPC: Gateway Endpoint (DynamoDB), a cloudonaut.io template'
Metadata:
'AWS::CloudFormation::Interface':
ParameterGroups:
Expand Down
2 changes: 1 addition & 1 deletion vpc/vpc-endpoint-s3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
AWSTemplateFormatVersion: '2010-09-09'
Description: 'VPC: Endpoint to S3 for private subnets, a cloudonaut.io template, contributed by https://github.com/btsuhako'
Description: 'VPC: Gateway Endpoint (S3), a cloudonaut.io template, contributed by https://github.com/btsuhako'
Metadata:
'AWS::CloudFormation::Interface':
ParameterGroups:
Expand Down
122 changes: 122 additions & 0 deletions vpc/vpc-endpoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
# Copyright 2018 widdix GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
AWSTemplateFormatVersion: '2010-09-09'
Description: 'VPC: Interface Endpoint, a cloudonaut.io template'
Metadata:
'AWS::CloudFormation::Interface':
ParameterGroups:
- Label:
default: 'Parent Stacks'
Parameters:
- ParentVPCStack
- ParentClientStack
- Label:
default: 'Endpoint Parameters'
Parameters:
- ServiceName
Parameters:
ParentVPCStack:
Description: 'Stack name of parent VPC stack based on vpc/vpc-*azs.yaml template.'
Type: String
ParentClientStack:
Description: 'Optionel stack name of parent client stack based on state/client-sg.yaml template.'
Type: String
ServiceName:
Description: 'The name of the service.'
Type: String
AllowedValues: # generate list with aws --region us-east-1 ec2 describe-vpc-endpoint-services --query 'ServiceDetails[].ServiceName'
- notebook
- cloudformation
- cloudtrail
- codebuild
- 'codebuild-fips'
- codecommit
- 'codecommit-fips'
- codepipeline
- config
- dynamodb
- ec2
- ec2messages
- 'ecr.api'
- 'ecr.dkr'
- ecs
- 'ecs-agent'
- 'ecs-telemetry'
- 'elastic-inference.runtime'
- elasticloadbalancing
- events
- 'execute-api'
- 'git-codecommit'
- 'git-codecommit-fips'
- 'kinesis-firehose'
- 'kinesis-streams'
- kms
- logs
- monitoring
- s3
- 'sagemaker.api'
- 'sagemaker.runtime'
- 'sagemaker.runtime-fips'
- secretsmanager
- servicecatalog
- sns
- sqs
- ssm
- ssmmessages
- transfer
- 'transfer.server'
Conditions:
HasParentClientStack: !Not [!Equals [!Ref ParentClientStack, '']]
Resources:
SecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: !Ref 'AWS::StackName'
VpcId: {'Fn::ImportValue': !Sub '${ParentVPCStack}-VPC'}
SecurityGroupIngress:
- !If
- HasParentClientStack
- IpProtocol: tcp
FromPort: 443
ToPort: 443
SourceSecurityGroupId: {'Fn::ImportValue': !Sub '${ParentClientStack}-ClientSecurityGroup'}
- IpProtocol: tcp
FromPort: 443
ToPort: 443
CidrIp: {'Fn::ImportValue': !Sub '${ParentVPCStack}-CidrBlock'}
Endpoint:
Type: 'AWS::EC2::VPCEndpoint'
Properties:
PrivateDnsEnabled: true
SecurityGroupIds: [!Ref SecurityGroup]
ServiceName: !Sub 'com.amazonaws.${AWS::Region}.${ServiceName}'
SubnetIds: !Split [',', {'Fn::ImportValue': !Sub '${ParentVPCStack}-SubnetsPrivate'}]
VpcEndpointType: Interface
VpcId: {'Fn::ImportValue': !Sub '${ParentVPCStack}-VPC'}
Outputs:
TemplateID:
Description: 'cloudonaut.io template id.'
Value: 'vpc/vpc-endpoint'
TemplateVersion:
Description: 'cloudonaut.io template version.'
Value: '__VERSION__'
StackName:
Description: 'Stack name.'
Value: !Sub '${AWS::StackName}'
Endpoint:
Description: 'The VPC endpoint to a service.'
Value: !Ref Endpoint
Export:
Name: !Sub '${AWS::StackName}-Endpoint'

0 comments on commit 6b31bd2

Please sign in to comment.