Amazon Web Services (AWS)

クラウドプラットフォームパブリッククラウドコンピューティングストレージデータベース機械学習サーバーレス

クラウドプラットフォーム

Amazon Web Services (AWS)

概要

Amazon Web Services (AWS)は、世界最大のクラウドサービスプロバイダーとして、200以上のサービスを提供する包括的なクラウドプラットフォームです。2006年の開始以来、企業のデジタル変革を支える中核的な存在として確立され、コンピュート、ストレージ、データベース、ネットワーキング、機械学習、分析、セキュリティなど幅広い分野でクラウドソリューションを提供しています。グローバルで33のリージョンと105のアベイラビリティーゾーンを運用し、世界中の企業が信頼性、スケーラビリティ、費用対効果に優れたクラウドサービスを利用できる環境を構築しています。

詳細

AWSは2025年現在、クラウド市場で約33%のシェアを維持するリーダーとして、継続的なイノベーションと新サービス展開を行っています。主力サービスには、仮想サーバーのAmazon EC2、オブジェクトストレージのAmazon S3、マネージドデータベースのAmazon RDS、機械学習プラットフォームのAmazon SageMaker、サーバーレスコンピューティングのAWS Lambdaなどがあります。2025年の注目機能として、Graviton3プロセッサーによる25%の電力効率向上、S3 Glacierの高速データ取得機能、SageMakerの拡張されたプリトレーニングモデル、リアルタイム分析機能の強化などがあります。また、pay-as-you-useの料金体系により、使用した分だけ課金される柔軟性の高いコスト構造を実現し、スタートアップから大企業まで幅広い規模のビジネスに対応しています。エンタープライズレベルのセキュリティ、コンプライアンス認証、24時間365日のサポート体制も特徴的です。

メリット・デメリット

メリット

  • 圧倒的なサービス数: 200以上の包括的なクラウドサービスによる一元管理
  • グローバルインフラ: 33リージョン・105アベイラビリティーゾーンの広範囲カバレッジ
  • 高い信頼性: 99.9%以上のSLA保証とエンタープライズグレードの可用性
  • 柔軟な料金体系: 従量課金制、予約インスタンス、スポットインスタンスによるコスト最適化
  • 豊富なエコシステム: 膨大なコミュニティ、教育リソース、パートナーネットワーク
  • 先進的な機械学習: SageMaker、Rekognition、Comprehendによる包括的なAI/MLソリューション
  • セキュリティ: 多層防御アーキテクチャとコンプライアンス認証の充実

デメリット

  • 複雑性: 多数のサービスと設定オプションによる学習コストの高さ
  • 予期しない課金: 複雑な料金体系による想定外の高額請求リスク
  • ベンダーロックイン: AWS固有のサービス依存による他クラウドへの移行困難性
  • コンソール操作: UIの複雑さと頻繁な変更による操作の習得困難
  • サポート費用: プロダクションサポートには追加料金が必要
  • 地域制約: 一部の新サービスは特定リージョンでのみ提供

参考ページ

書き方の例

初期設定とCLI

# AWS CLIのインストール
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

# AWS CLIの設定
aws configure
# AWS Access Key ID: YOUR_ACCESS_KEY
# AWS Secret Access Key: YOUR_SECRET_KEY
# Default region name: ap-northeast-1
# Default output format: json

# プロファイル設定(複数アカウント管理)
aws configure --profile production
aws configure --profile development

# 設定確認
aws sts get-caller-identity
aws sts get-caller-identity --profile production

# リージョン一覧の取得
aws ec2 describe-regions --output table

# 現在のAWSアカウント情報表示
aws sts get-caller-identity --query 'Account' --output text

主要サービス(コンピュート)

# EC2インスタンスの作成
aws ec2 run-instances \
  --image-id ami-0c3fd0f5d33134a76 \
  --instance-type t3.micro \
  --key-name my-key-pair \
  --security-group-ids sg-12345678 \
  --subnet-id subnet-12345678 \
  --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=WebServer}]'

# インスタンス一覧の表示
aws ec2 describe-instances \
  --query 'Reservations[*].Instances[*].[InstanceId,InstanceType,State.Name,PublicIpAddress,Tags[?Key==`Name`].Value|[0]]' \
  --output table

# インスタンスの開始・停止
aws ec2 start-instances --instance-ids i-1234567890abcdef0
aws ec2 stop-instances --instance-ids i-1234567890abcdef0

# Auto Scalingグループの作成
aws autoscaling create-auto-scaling-group \
  --auto-scaling-group-name my-asg \
  --launch-template LaunchTemplateName=my-template,Version=1 \
  --min-size 1 \
  --max-size 5 \
  --desired-capacity 2 \
  --vpc-zone-identifier "subnet-12345678,subnet-87654321"

# Elastic Load Balancerの作成
aws elbv2 create-load-balancer \
  --name my-application-load-balancer \
  --subnets subnet-12345678 subnet-87654321 \
  --security-groups sg-12345678

ストレージサービス

# S3バケットの作成
aws s3 mb s3://my-unique-bucket-name-12345

# ファイルのアップロード
aws s3 cp localfile.txt s3://my-unique-bucket-name-12345/
aws s3 cp ./website/ s3://my-unique-bucket-name-12345/ --recursive

# ファイルの同期
aws s3 sync ./local-folder s3://my-unique-bucket-name-12345/remote-folder/

# バケットポリシーの設定
cat > bucket-policy.json << EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicReadGetObject",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::my-unique-bucket-name-12345/*"
    }
  ]
}
EOF

aws s3api put-bucket-policy \
  --bucket my-unique-bucket-name-12345 \
  --policy file://bucket-policy.json

# バージョニングの有効化
aws s3api put-bucket-versioning \
  --bucket my-unique-bucket-name-12345 \
  --versioning-configuration Status=Enabled

# ライフサイクルポリシーの設定
cat > lifecycle.json << EOF
{
  "Rules": [
    {
      "ID": "ArchiveRule",
      "Status": "Enabled",
      "Filter": {"Prefix": "documents/"},
      "Transitions": [
        {
          "Days": 30,
          "StorageClass": "STANDARD_IA"
        },
        {
          "Days": 365,
          "StorageClass": "GLACIER"
        }
      ]
    }
  ]
}
EOF

aws s3api put-bucket-lifecycle-configuration \
  --bucket my-unique-bucket-name-12345 \
  --lifecycle-configuration file://lifecycle.json

データベースサービス

# RDS PostgreSQLインスタンスの作成
aws rds create-db-instance \
  --db-instance-identifier myapp-postgres \
  --db-instance-class db.t3.micro \
  --engine postgres \
  --engine-version 14.9 \
  --allocated-storage 20 \
  --storage-type gp2 \
  --db-name myappdb \
  --master-username admin \
  --master-user-password MySecurePassword123 \
  --vpc-security-group-ids sg-12345678 \
  --backup-retention-period 7 \
  --storage-encrypted

# DynamoDBテーブルの作成
aws dynamodb create-table \
  --table-name Users \
  --attribute-definitions \
    AttributeName=UserId,AttributeType=S \
  --key-schema \
    AttributeName=UserId,KeyType=HASH \
  --provisioned-throughput \
    ReadCapacityUnits=5,WriteCapacityUnits=5

# DynamoDBデータの操作
aws dynamodb put-item \
  --table-name Users \
  --item '{
    "UserId": {"S": "user123"},
    "Name": {"S": "田中太郎"},
    "Email": {"S": "[email protected]"},
    "CreatedAt": {"S": "2025-01-01T00:00:00Z"}
  }'

aws dynamodb get-item \
  --table-name Users \
  --key '{"UserId": {"S": "user123"}}'

# ElastiCacheクラスターの作成
aws elasticache create-cache-cluster \
  --cache-cluster-id my-redis-cluster \
  --cache-node-type cache.t3.micro \
  --engine redis \
  --num-cache-nodes 1 \
  --cache-subnet-group-name my-cache-subnet-group \
  --security-group-ids sg-12345678

ネットワーク設定

# VPCの作成
aws ec2 create-vpc \
  --cidr-block 10.0.0.0/16 \
  --tag-specifications 'ResourceType=vpc,Tags=[{Key=Name,Value=MyVPC}]'

# サブネットの作成
aws ec2 create-subnet \
  --vpc-id vpc-12345678 \
  --cidr-block 10.0.1.0/24 \
  --availability-zone ap-northeast-1a \
  --tag-specifications 'ResourceType=subnet,Tags=[{Key=Name,Value=PublicSubnet}]'

aws ec2 create-subnet \
  --vpc-id vpc-12345678 \
  --cidr-block 10.0.2.0/24 \
  --availability-zone ap-northeast-1c \
  --tag-specifications 'ResourceType=subnet,Tags=[{Key=Name,Value=PrivateSubnet}]'

# インターネットゲートウェイの作成と接続
aws ec2 create-internet-gateway \
  --tag-specifications 'ResourceType=internet-gateway,Tags=[{Key=Name,Value=MyIGW}]'

aws ec2 attach-internet-gateway \
  --internet-gateway-id igw-12345678 \
  --vpc-id vpc-12345678

# セキュリティグループの作成
aws ec2 create-security-group \
  --group-name web-server-sg \
  --description "Security group for web servers" \
  --vpc-id vpc-12345678

# セキュリティグループルールの追加
aws ec2 authorize-security-group-ingress \
  --group-id sg-12345678 \
  --protocol tcp \
  --port 80 \
  --cidr 0.0.0.0/0

aws ec2 authorize-security-group-ingress \
  --group-id sg-12345678 \
  --protocol tcp \
  --port 443 \
  --cidr 0.0.0.0/0

# ルートテーブルの設定
aws ec2 create-route \
  --route-table-id rtb-12345678 \
  --destination-cidr-block 0.0.0.0/0 \
  --gateway-id igw-12345678

サーバーレスとAPI

# Lambda関数のパッケージ作成
cat > index.js << EOF
exports.handler = async (event) => {
  const response = {
    statusCode: 200,
    body: JSON.stringify({
      message: 'Hello from Lambda!',
      timestamp: new Date().toISOString(),
      event: event
    })
  };
  return response;
};
EOF

zip function.zip index.js

# Lambda関数の作成
aws lambda create-function \
  --function-name my-hello-function \
  --runtime nodejs18.x \
  --role arn:aws:iam::123456789012:role/lambda-execution-role \
  --handler index.handler \
  --zip-file fileb://function.zip

# Lambda関数の実行
aws lambda invoke \
  --function-name my-hello-function \
  --payload '{"key1": "value1", "key2": "value2"}' \
  response.json

# API Gatewayの作成
aws apigateway create-rest-api \
  --name my-api \
  --description "My REST API"

# CloudFormationスタックのデプロイ
cat > template.yaml << EOF
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: src/
      Handler: app.lambdaHandler
      Runtime: nodejs18.x
      Events:
        HelloWorld:
          Type: Api
          Properties:
            Path: /hello
            Method: get
EOF

aws cloudformation package \
  --template-file template.yaml \
  --s3-bucket my-deployment-bucket \
  --output-template-file packaged-template.yaml

aws cloudformation deploy \
  --template-file packaged-template.yaml \
  --stack-name my-serverless-app \
  --capabilities CAPABILITY_IAM

デプロイメントとCI/CD

# CodeCommitリポジトリの作成
aws codecommit create-repository \
  --repository-name my-app-repo \
  --repository-description "My application repository"

# CodeBuildプロジェクトの作成
cat > buildspec.yml << EOF
version: 0.2
phases:
  pre_build:
    commands:
      - echo Logging in to Amazon ECR...
      - aws ecr get-login-password --region \$AWS_DEFAULT_REGION | docker login --username AWS --password-stdin \$AWS_ACCOUNT_ID.dkr.ecr.\$AWS_DEFAULT_REGION.amazonaws.com
  build:
    commands:
      - echo Build started on \`date\`
      - echo Building the Docker image...
      - docker build -t \$IMAGE_REPO_NAME:latest .
      - docker tag \$IMAGE_REPO_NAME:latest \$AWS_ACCOUNT_ID.dkr.ecr.\$AWS_DEFAULT_REGION.amazonaws.com/\$IMAGE_REPO_NAME:latest
  post_build:
    commands:
      - echo Build completed on \`date\`
      - echo Pushing the Docker image...
      - docker push \$AWS_ACCOUNT_ID.dkr.ecr.\$AWS_DEFAULT_REGION.amazonaws.com/\$IMAGE_REPO_NAME:latest
EOF

aws codebuild create-project \
  --name my-build-project \
  --source type=CODECOMMIT,location=https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/my-app-repo \
  --artifacts type=NO_ARTIFACTS \
  --environment type=LINUX_CONTAINER,image=aws/codebuild/standard:5.0,computeType=BUILD_GENERAL1_MEDIUM \
  --service-role arn:aws:iam::123456789012:role/CodeBuildServiceRole

# CodePipelineの作成
cat > pipeline.json << EOF
{
  "pipeline": {
    "name": "my-pipeline",
    "roleArn": "arn:aws:iam::123456789012:role/CodePipelineServiceRole",
    "artifactStore": {
      "type": "S3",
      "location": "my-pipeline-artifacts-bucket"
    },
    "stages": [
      {
        "name": "Source",
        "actions": [
          {
            "name": "Source",
            "actionTypeId": {
              "category": "Source",
              "owner": "AWS",
              "provider": "CodeCommit",
              "version": "1"
            },
            "configuration": {
              "RepositoryName": "my-app-repo",
              "BranchName": "main"
            },
            "outputArtifacts": [{"name": "SourceOutput"}]
          }
        ]
      },
      {
        "name": "Build",
        "actions": [
          {
            "name": "Build",
            "actionTypeId": {
              "category": "Build",
              "owner": "AWS",
              "provider": "CodeBuild",
              "version": "1"
            },
            "configuration": {
              "ProjectName": "my-build-project"
            },
            "inputArtifacts": [{"name": "SourceOutput"}],
            "outputArtifacts": [{"name": "BuildOutput"}]
          }
        ]
      }
    ]
  }
}
EOF

aws codepipeline create-pipeline --cli-input-json file://pipeline.json