m6web/aws-bundle

此包已被废弃且不再维护。作者建议使用 aws/aws-sdk-php-symfony 包。
关于此包的最新版本(v2.0.2)没有可用的许可证信息。

Bundle 客户端 AWS

v2.0.2 2017-04-10 09:28 UTC

README

Aws 客户端作为 Symfony 服务

⚠ 此包已过时

请使用官方的 AWS Symfony 包 代替。

配置您的 AWS 用户凭证和服务

AWS 配置服务的参考指南。见 AWS 配置参考

  • m6_web_aws:
    • credentials: # AWS 用户凭证列表

      • default: AWS 用户名称
        • key: "azerty" [可选] 您的 AWS 用户访问密钥 ID。见 AWS 访问密钥
        • secret: "1337" [可选] 您的 AWS 用户秘密访问密钥。见 AWS 访问密钥
        • region: "us-west-2" [可选] 区域名称(例如,'us-east-1','us-west-1','us-west-2','eu-west-1' 等)
        • scheme: [可选] 基础 URL 的 URI 方案(例如,'https','http'),当未提供 base_url 时使用。
        • base_url: [可选] 允许您指定自定义端点,而不是让 SDK 自动根据区域和方案构建端点。
        • signature: [可选]
        • signature_service: [可选] signature.service 的别名。Signature V4 的签名服务范围。见 设置自定义端点
        • signature_region: [可选] signature.region 的别名。Signature V4 的签名区域范围。见 设置自定义端点
        • curl_options: [可选] curl.options 的别名
        • request_options: [可选] request.options 的别名
        • command_params: [可选] command.params 的别名
      • ops: # 另一个 AWS 用户
        • key: ...
        • secret:
        • region:
    • clients:

      • 6cloud_cdn:
        • credential: "default" [可选] AWS 用户名
        • service: "S3" [必需] AWS 服务别名(见下文)
        • region: "us-west-1" [可选] 覆盖区域名称。
    • s3:

      • buckets:
        • dev: 桶的名称(用于定义服务名称)
          • name: "s3-bucket-name" 桶的真实名称
          • client: "6cloud_cdn" 上面定义的客户端名称
    • sqs:

      • dev: sqs 配置的名称(用于定义服务名称)
        • client: "sqs_client" 上面定义的客户端名称
    • sts:

      • dev: sts 配置的名称(用于定义服务名称)
        • client: "sts_client" 上面定义的客户端名称
    • dynamodb:

      • dev: 客户端的名称
        • client: "6cloud_cdn" 上面定义的客户端名称

AWS 服务的别名

(区分大小写)

  • AutoScaling
  • CloudFormation
  • CloudFront
  • cloudfront (版本:2012-05-05)
  • CloudSearch
  • cloudsearch (版本:2011-02-01)
  • CloudTrail
  • CloudWatch
  • DataPipeline
  • DirectConnect
  • DynamoDb
  • dynamodb (版本: 2011-12-05)
  • Ec2
  • ElastiCache
  • ElasticBeanstalk
  • ElasticLoadBalancing
  • ElasticTranscoder
  • Emr
  • Glacier
  • Kinesis
  • Iam
  • ImportExport
  • OpsWorks
  • Rds
  • Redshift
  • Route53
  • S3
  • SimpleDb
  • Ses
  • Sns
  • Sqs
  • StorageGateway
  • Sts
  • Support
  • Swf

SQS 示例

    $client = $this->getContainer()->get('m6web_aws.sqs.workers');
    $queue = $client->getQueue('queue_test');

    for ($i=0; $i<100; $i++) {
        echo $client->sendMessage($queue, "hello world $i") . "\n";
    }

    $i = 0;
    while($messages = $client->receiveMessage($queue, 10)) {
        foreach($messages as $message) {
            echo $message['Body'] . "... ";
            if ($client->deleteMessage($queue, $message['ReceiptHandle'])) {
                echo "OK\n";
                $i++;
            } else echo "ERROR\n";
        }
    }

    echo"\n===> READ : $i\n";

STS 示例

    $client = $this->getContainer()->get('m6web_aws.sts.m6');

    $sessionToken = $client->getSessionToken();
    $credentials  = $client->createCredentials($sessionToken);

    echo "Key : " . $credentials->getSecretKey() . "\n";
    echo "Token : " . $credentials->getSecurityToken() . "\n";

数据收集器

数据收集器默认启用。

要禁用

m6_web_aws:
    disable_data_collector: true

单元测试

    composer install
    ./bin/atoum