LoginSignup
0
0

More than 5 years have passed since last update.

re:inventで発表されたX-Rayを試そうとしてみた

Last updated at Posted at 2016-12-01

プレビューを申し込んですぐに利用可能になったので、早速トライしてみました。

TOPページ

スクリーンショット 2016-12-01 10.01.28.png
previewついてますね。

Get Started

ちゃんとガイド付きです。「Launch ~」を選択すると、サンプルアプリが起動します。
スクリーンショット 2016-12-01 10.01.38.png

ちゃんと削除する方法まで載っていて、CloudFormationあまり使わない人にも親切です。
スクリーンショット 2016-12-01 10.05.58.png

ここから先は従来通りのCloudFormationでのスタック起動作業です。
スクリーンショット 2016-12-01 10.06.10.png

既存アプリに採用する場合

言語がnodeJavaC++の3つに限られる様子です。
スクリーンショット 2016-12-01 10.01.47.png

nodeを選びましたが、インスタンスにデーモンを入れるかsdkをアプリに組み込むかを求められます。
スクリーンショット 2016-12-01 10.01.57.png

なお

テストのCloudFormationですが、基調講演に集中せずに使おうとしたバチがあたったのか、コケました。
スクリーンショット 2016-12-01 10.13.49.png

あとでちゃんとやりなおします。

とりあえずごめんなさいの気持ちと共に基調講演の話を聞く姿勢に戻ります。

追記

default VPCがない状態になってるアカウントで試したために起きた問題っぽいです。
最近作ったアカウントで動かしたところ、問題なく動きました。

[おまけ]X-RayサンプルアプリのCFN

CloudFormationでサンプルアプリ作るらしいので、そのテンプレートを引っこ抜いてみました。
以下がそれ。

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  SampleInstanceProfileRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Sid: ''
          Effect: Allow
          Principal:
            Service:
            - ec2.amazonaws.com
          Action: sts:AssumeRole
      ManagedPolicyArns:
      - arn:aws:iam::aws:policy/AWSElasticBeanstalkWebTier
  XRayWriteOnlyPolicy:
    Type: AWS::IAM::Policy
    Properties:
      PolicyName: AWSXRayWriteOnlyPolicy
      PolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Effect: Allow
          Action:
          - sns:Publish
          - xray:PutTelemetryRecords
          - xray:PutTraceSegments
          - dynamodb:PutItem
          Resource:
          - "*"
      Roles:
      - Ref: SampleInstanceProfileRole
  SampleInstanceProfile:
    Type: AWS::IAM::InstanceProfile
    Properties:
      Path: "/"
      Roles:
      - Ref: SampleInstanceProfileRole
  SampleEBServiceRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Sid: ''
          Effect: Allow
          Principal:
            Service: elasticbeanstalk.amazonaws.com
          Action: sts:AssumeRole
          Condition:
            StringEquals:
              sts:ExternalId: elasticbeanstalk
      ManagedPolicyArns:
      - arn:aws:iam::aws:policy/service-role/AWSElasticBeanstalkService
      - arn:aws:iam::aws:policy/service-role/AWSElasticBeanstalkEnhancedHealth
  ElasticBeanstalkApplication:
    Type: AWS::ElasticBeanstalk::Application
    Properties:
      ApplicationName: 
        Ref: AWS::StackName
  ElasticBeanstalkApplicationVersion:
    Type: AWS::ElasticBeanstalk::ApplicationVersion
    Properties:
      ApplicationName:
        Ref: ElasticBeanstalkApplication
      SourceBundle:
        S3Bucket:
          Fn::Join:
          - "."
          - - aws-xray-assets
            - Ref: AWS::Region
        S3Key: samples/aws-xray-node-sample-app.zip
  ElasticBeanstalkEnvironment:
    Type: AWS::ElasticBeanstalk::Environment
    Properties:
      ApplicationName:
        Ref: ElasticBeanstalkApplication
      Description: AWS X-Ray Getting Started Sample Application
      EnvironmentName:
        Ref: AWS::StackName
      OptionSettings:
      - Namespace: aws:autoscaling:launchconfiguration
        OptionName: InstanceType
        Value: c4.large
      - Namespace: aws:autoscaling:launchconfiguration
        OptionName: IamInstanceProfile
        Value:
          Ref: SampleInstanceProfile
      - Namespace: aws:elasticbeanstalk:environment
        OptionName: ServiceRole
        Value: aws-xray-sample-eb-service-role
      - Namespace: aws:elasticbeanstalk:environment
        OptionName: EnvironmentType
        Value: SingleInstance
      - Namespace: aws:elasticbeanstalk:healthreporting:system
        OptionName: SystemType
        Value: enhanced
      SolutionStackName: 64bit Amazon Linux 2016.09 v3.1.0 running Node.js
      VersionLabel:
        Ref: ElasticBeanstalkApplicationVersion
Outputs:
  ElasticBeanstalkEnvironmentURL:
    Description: URL for the Elastic Beanstalk Getting Started Sample Application
    Value:
      Fn::GetAtt:
      - ElasticBeanstalkEnvironment
      - EndpointURL
  SampleInstanceProfileRole:
    Description: IAM Role used for AWS X-Ray Getting Started Sample Application
    Value:
      Fn::GetAtt:
      - SampleInstanceProfileRole
      - Arn
  SampleInstanceProfile:
    Description: Instance Profile used for AWS X-Ray Getting Started Sample Application
    Value:
      Ref: SampleInstanceProfile
  SampleEBServiceRole:
    Description: IAM Role used for AWS Elastic Beanstalk Service Role
    Value:
      Fn::GetAtt:
      - SampleEBServiceRole
      - Arn
0
0
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
0
0