
Cloud One ConformityでCloudFormationテンプレートスキャンを試してみた
この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
こんにちは、コンサル部@大阪オフィスのTodaです。
トレンドマイクロ社が提供しているCloud One Conformityを試す機会がありましたので所有するAWS環境に設定してみました。
Cloud One Conformityとは?
Cloud One Conformityはクラウドインフラストラクチャを継続監視してセキュリティ、コンプライアンス対応状況の確認、可視化、レポート、自動修復をするソリューションです。
クラウド環境はAWSおよびAzureに対応、SOC2、ISO 27001、NIST、CIS、GDPR、PCI DSS、GDPR、HIPAA、AWSおよびAzure Well-Architected Framework、CIS Microsoft Azure Foundations Security Benchmarkなどのベストプラクティスチェックに対応して継続的なチェックをおこないます。
■ Cloud One Conformity
https://www.trendmicro.com/ja_jp/business/products/hybrid-cloud/cloud-one-conformity.html
■ Cloud One Conformity 説明動画
www.trendmicro.com/ja_jp/business/products/hybrid-cloud/cloud-one-conformity.html?modal=s3a-icon-demo-0a5fe5  
今回はConformityで利用できるCloudFormationテンプレートスキャナの機能を試してみます。
■ Cloud One Conformity Template Scanner
https://www.cloudconformity.com/help/template-scanner.html
前提条件
Conformityを試すため Cloud One のアカウント登録をおこないます。
登録後、30日間の体験版にて操作をしております。
テンプレートスキャンについて
ConformityにはCloudFormationの内容をあらかじめチェックしてルールに違反する設定を確認する事ができます。 スキャン時のルールは下記3点から選びます。
- Default rule settings (標準のルール)
- Profile rule settings (プロファイルに設定されているルール)
- Account rule settings (アカウントに設定されているルール)
テンプレートスキャン操作
ダッシュボードの表示
Cloud Oneにログインをおこない、プラットフォームメニューから[Conformity]を選択します。 画面上部の[Template Scanner]をクリックします。

テンプレートスキャンの設定
CloudFormationのテンプレートを指定とチェックルールの選択があります。
ルール選択で Profile / Account を選択するとセレクトボックスが表示されて対象を指定します。

テストテンプレート
今回はVPC / Subnet(Public2 Private2)を作るテンプレートを用意しました。
AWSTemplateFormatVersion: '2010-09-09'
Metadata:
  AWS::CloudFormation::Interface:
    ParameterGroups:
      - Label:
          default: "VPC"
        Parameters:
          - Env
          - VpcCidr
Parameters:
  Env:
    Default: prod
    Type: String
  VpcCidr:
    Default: 10.1.0.0/16
    Type: String
Resources:
  # ------------------------------------------------------------- #
  # VPC
  # ------------------------------------------------------------- #
  # Create VPC
  Vpc:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: !Ref VpcCidr
      EnableDnsSupport: 'true'
      EnableDnsHostnames: 'true'
      InstanceTenancy: default
      Tags:
        - Key: Name
          Value: !Sub ${Env}-vpc
  # Create InternetGateway
  InternetGateway:
    Type: AWS::EC2::InternetGateway
    Properties:
      Tags:
        - Key: Name
          Value: !Sub ${Env}-igw
  # Attach InternetGateway VPC
  InternetGatewayAttach:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId: !Ref Vpc
      InternetGatewayId: !Ref InternetGateway
ファイルに保存後、チェック処理をおこないます。
結果
VPC/Subnetはチェック項目が少ないため2件のルール違反が検出されました。
- VPC Flow Logs が有効でない
- タグが設定されていない

違反の改善
VPC Flow Logsとタグの設定をおこなってみます。
修正後は再度チェックを実行します。
・修正後
AWSTemplateFormatVersion: '2010-09-09'
Metadata:
  AWS::CloudFormation::Interface:
    ParameterGroups:
      - Label:
          default: "VPC"
        Parameters:
          - Env
          - VpcCidr
Parameters:
  Env:
    Default: prod
    Type: String
  VpcCidr:
    Default: 10.1.0.0/16
    Type: String
Resources:
  # ------------------------------------------------------------- #
  # VPC
  # ------------------------------------------------------------- #
  # Create VPC (タグ設定を部分追加)
  Vpc:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: !Ref VpcCidr
      EnableDnsSupport: 'true'
      EnableDnsHostnames: 'true'
      InstanceTenancy: default
      Tags:
        - Key: Name
          Value: !Sub ${Env}-vpc
        - Key: "Role"
          Value: "Test"
        - Key: "Environment"
          Value: "Testing"
        - Key: "Owner"
          Value: "Admin"
  # Create InternetGateway
  InternetGateway:
    Type: AWS::EC2::InternetGateway
    Properties:
      Tags:
        - Key: Name
          Value: !Sub ${Env}-igw
  # Attach InternetGateway VPC
  InternetGatewayAttach:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId: !Ref Vpc
      InternetGatewayId: !Ref InternetGateway
  # ------------------------------------------------------------- #
  # VPC Flow Logs
  # ------------------------------------------------------------- #
  # Create PC Flow Logs (設定を追加)
  VPCFlowLogs:
    Type: AWS::EC2::FlowLog
    Properties:
      LogDestination: "arn:aws:s3:::toda-xxxxxxxxxxxxx"
      LogDestinationType: s3
      ResourceId: !Ref Vpc
      ResourceType: "VPC"
      TrafficType: "ACCEPT"
再チェックをすると、先ほどの違反が全てSUCCESSに変わっています。
CloudFormationを環境に適用する前に機械的なチェックができるのは人為的なミス防止にも役に立ちそうです。

他のCfnも試してみる
ルールが多いS3を生成するCloudFormationをチェックしてみました。
結果はSUCCESS/FAILUREどちらも表示されて対応できてる・できていないが把握できるようになっています。

さいごに
今回はCloud One Conformityに用意されているCloudFormationテンプレートスキャナの機能を試してみました。
CloudFormationはCloudFormation Guardでコンプライアンスチェックをする方法がございますが、Conformityでも事前の確認をする事ができ、安全なデプロイが実現できるようになります。
少しでもお客様の参考になればと考えております。









