LoginSignup
10
5

More than 5 years have passed since last update.

CloudFormationを使ってVPC S3エンドポイントを構築する

Posted at

はじめに

本記事では、AWS CloudFormation管理コンソールを使って、VPC S3エンドポイントを構築する手順を説明しています。(初心者向け)

本記事で掲載しているテンプレートの最新版は、下記に置いてます。
https://github.com/okubo-t/aws-cloudformation

構成図

前提条件

下記の記事の構築手順で、VPCを構築していること。
CloudFormationを使ってVPCを構築する

PJPrefixの値は、同一にすること。

構築手順

1 AWS CloudFormation管理コンソールから、スタックの作成をクリックします。

2 後述のテンプレートを選択します。

3 各パラメータを入力します。

パラメータ名 用途 備考
スタックの名前 テンプレートから作成するリソース一式の名前 例 prd-stack-nat-20180801
PJPrefix 構築するプロジェクトの環境を識別するために各コンポーネントの先頭に付与する識別子 例 qiita-prd

4 後続は、デフォルトのまま次へ次へで、作成します。
状況が CREATE COMPLETEになれば、VPC S3エンドポイントの構築が完了です。

テンプレート

vpc-s3endpoint.yml
AWSTemplateFormatVersion: "2010-09-09"
Description: 
  VPCS3Endpoint Create

Metadata: 
  "AWS::CloudFormation::Interface": 
    ParameterGroups: 
      - Label: 
          default: "Project Name Prefix"
        Parameters: 
          - PJPrefix

# ------------------------------------------------------------#
# Input Parameters
# ------------------------------------------------------------# 
Parameters:
  PJPrefix:
    Type: String

Resources:
# ------------------------------------------------------------#
#  VPCS3Endpoint
# ------------------------------------------------------------#
  VPCS3Endpoint:
    Type: "AWS::EC2::VPCEndpoint"
    Properties:
      RouteTableIds: 
        - { "Fn::ImportValue": !Sub "${PJPrefix}-private-route-a" }
        - { "Fn::ImportValue": !Sub "${PJPrefix}-private-route-c" }
      ServiceName: !Sub "com.amazonaws.${AWS::Region}.s3"
      VpcId: { "Fn::ImportValue": !Sub "${PJPrefix}-vpc" }

# ------------------------------------------------------------#
# Output Parameters
# ------------------------------------------------------------# 
Outputs:
  VPCS3Endpoint:
    Value: !Ref VPCS3Endpoint
    Export:
      Name: !Sub "${PJPrefix}-vpcs3endpoint-id"
10
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
5