Skip to content

Commit 3cc3453

Browse files
PHP: Adds metadata file and support for creating the Express subdirectory in S3 for PHP, and moves those files. (#7094)
* Adds metadata file and support for creating the Express subdirectory in S3 for PHP, and moves those files. Co-authored-by: Laren-AWS <[email protected]> --------- Co-authored-by: Laren-AWS <[email protected]>
1 parent 529c7f0 commit 3cc3453

File tree

9 files changed

+135
-59
lines changed

9 files changed

+135
-59
lines changed

.doc_gen/cross-content/phrases-code-examples.ent

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,6 @@
162162
<!ENTITY CFJS10 'JavaScript runtime 1.0 for &CF; Functions'>
163163
<!ENTITY CFJS20long 'JavaScript runtime 2.0 for &CFlong; Functions'>
164164
<!ENTITY CFJS20 'JavaScript runtime 2.0 for &CF; Functions'>
165+
166+
<!-- S3 only entity to account for super-short usage -->
167+
<!ENTITY S3only 'S3'>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
s3-directory-buckets_Scenario_ExpressBasics:
2+
synopsis_list:
3+
- Set up a VPC and VPC Endpoint
4+
- Set up the S3 Express Policies, Roles, and User to work with S3 Express buckets
5+
- Create two S3 Clients
6+
- Create two buckets
7+
- Create an object and copy it over
8+
- Demonstrate performance difference
9+
- Populate the buckets to show the lexicographical difference
10+
- Prompt the user to see if they want to clean up the resources
11+
category: Basics
12+
languages:
13+
PHP:
14+
versions:
15+
- sdk_version: 3
16+
github: php/example_code/s3/express
17+
sdkguide:
18+
excerpts:
19+
- description: Run a scenario demonstrating the basics of &S3; Express One Zone.
20+
snippet_tags:
21+
- php.example_code.s3.ExpressBasics
22+
- php.example_code.s3.service.S3Service
23+
services:
24+
s3-directory-buckets: {CreateBucket, CopyObject, GetObject, PutObject, ListObjects, DeleteObject, DeleteBucket}

.doc_gen/metadata/s3_metadata.yaml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3481,32 +3481,6 @@ s3_Scenario_ConditionalRequests:
34813481
- python.example_code.s3.S3ConditionalRequests.wrapper
34823482
services:
34833483
s3: {GetObject, PutObject, CopyObject}
3484-
s3_Scenario_ExpressBasics:
3485-
title: Learn the basics of Amazon S3 Express One Zone with an &AWS; SDK
3486-
title_abbrev: Learn the basics of S3 Express One Zone
3487-
synopsis_list:
3488-
- Set up a VPC and VPC Endpoint
3489-
- Set up the S3 Express Policies, Roles, and User to work with S3 Express buckets
3490-
- Create two S3 Clients
3491-
- Create two buckets
3492-
- Create an object and copy it over
3493-
- Demonstrate performance difference
3494-
- Populate the buckets to show the lexicographical difference
3495-
- Prompt the user to see if they want to clean up the resources
3496-
category: Basics
3497-
languages:
3498-
PHP:
3499-
versions:
3500-
- sdk_version: 3
3501-
github: php/example_code/s3
3502-
sdkguide:
3503-
excerpts:
3504-
- description:
3505-
snippet_tags:
3506-
- php.example_code.s3.ExpressBasics
3507-
- php.example_code.s3.service.S3Service
3508-
services:
3509-
s3: {CreateVpc, DescribeRouteTables, CreateVpcEndpoint, CreateBucket, CopyObject, GetObject, PutObject, ListObjects, DeleteObject, DeleteBucket, DeleteVpcEndpoint, DeleteVpc}
35103484
s3_Scenario_DownloadS3Directory:
35113485
title: Download S3 'directories' from an &S3long; (&S3;) bucket
35123486
title_abbrev: Download S3 'directories'

.tools/readmes/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@
124124
"base_folder": "php",
125125
"service_folder": 'php/example_code/{{service["name"]}}',
126126
"sdk_api_ref": 'https://docs.aws.amazon.com/aws-sdk-php/v3/api/namespace-Aws.{{service["name"] | capitalize}}.html',
127+
"service_folder_overrides": {
128+
"s3-directory-buckets": "php/example_code/s3/express",
129+
}
127130
}
128131
},
129132
"Python": {

php/example_code/s3/README.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ For prerequisites, see the [README](../../README.md#Prerequisites) in the `php`
3939
Code examples that show you how to perform the essential operations within a service.
4040

4141
- [Learn the basics](GettingStartedWithS3.php)
42-
- [Learn the basics of S3 Express One Zone](S3ExpressBasics.php)
4342

4443

4544
### Single actions
@@ -97,26 +96,6 @@ This example shows you how to do the following:
9796
<!--custom.basics.s3_Scenario_GettingStarted.start-->
9897
<!--custom.basics.s3_Scenario_GettingStarted.end-->
9998

100-
#### Learn the basics of S3 Express One Zone
101-
102-
This example shows you how to do the following:
103-
104-
- Set up a VPC and VPC Endpoint
105-
- Set up the S3 Express Policies, Roles, and User to work with S3 Express buckets
106-
- Create two S3 Clients
107-
- Create two buckets
108-
- Create an object and copy it over
109-
- Demonstrate performance difference
110-
- Populate the buckets to show the lexicographical difference
111-
- Prompt the user to see if they want to clean up the resources
112-
113-
<!--custom.basic_prereqs.s3_Scenario_ExpressBasics.start-->
114-
<!--custom.basic_prereqs.s3_Scenario_ExpressBasics.end-->
115-
116-
117-
<!--custom.basics.s3_Scenario_ExpressBasics.start-->
118-
<!--custom.basics.s3_Scenario_ExpressBasics.end-->
119-
12099

121100
#### Create a presigned URL
122101

php/example_code/s3/ExpressRunner.php renamed to php/example_code/s3/express/ExpressRunner.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Aws\Exception\AwsException;
88
use AwsUtilities\RunnableExample;
9+
use S3\express\S3ExpressBasics;
910

1011
require_once __DIR__ . "/vendor/autoload.php";
1112

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# S3 Directory Buckets code examples for the SDK for PHP
2+
3+
## Overview
4+
5+
Shows how to use the AWS SDK for PHP to work with Amazon S3 Directory Buckets.
6+
7+
<!--custom.overview.start-->
8+
<!--custom.overview.end-->
9+
10+
_S3 Directory Buckets are designed to store data within a single AWS Zone. Directory buckets organize data hierarchically into directories, providing a structure similar to a file system._
11+
12+
## ⚠ Important
13+
14+
* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/).
15+
* Running the tests might result in charges to your AWS account.
16+
* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
17+
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).
18+
19+
<!--custom.important.start-->
20+
<!--custom.important.end-->
21+
22+
## Code examples
23+
24+
### Prerequisites
25+
26+
For prerequisites, see the [README](../../../README.md#Prerequisites) in the `php` folder.
27+
28+
29+
<!--custom.prerequisites.start-->
30+
<!--custom.prerequisites.end-->
31+
32+
### Basics
33+
34+
Code examples that show you how to perform the essential operations within a service.
35+
36+
- [Learn the basics](S3ExpressBasics.php)
37+
38+
39+
<!--custom.examples.start-->
40+
<!--custom.examples.end-->
41+
42+
## Run the examples
43+
44+
### Instructions
45+
46+
47+
<!--custom.instructions.start-->
48+
<!--custom.instructions.end-->
49+
50+
51+
#### Learn the basics
52+
53+
This example shows you how to do the following:
54+
55+
- Set up a VPC and VPC Endpoint
56+
- Set up the S3 Express Policies, Roles, and User to work with S3 Express buckets
57+
- Create two S3 Clients
58+
- Create two buckets
59+
- Create an object and copy it over
60+
- Demonstrate performance difference
61+
- Populate the buckets to show the lexicographical difference
62+
- Prompt the user to see if they want to clean up the resources
63+
64+
<!--custom.basic_prereqs.s3-directory-buckets_Scenario_ExpressBasics.start-->
65+
<!--custom.basic_prereqs.s3-directory-buckets_Scenario_ExpressBasics.end-->
66+
67+
68+
<!--custom.basics.s3-directory-buckets_Scenario_ExpressBasics.start-->
69+
<!--custom.basics.s3-directory-buckets_Scenario_ExpressBasics.end-->
70+
71+
72+
### Tests
73+
74+
⚠ Running tests might result in charges to your AWS account.
75+
76+
77+
To find instructions for running these tests, see the [README](../../../README.md#Tests)
78+
in the `php` folder.
79+
80+
81+
82+
<!--custom.tests.start-->
83+
<!--custom.tests.end-->
84+
85+
## Additional resources
86+
87+
- [S3 Directory Buckets User Guide](https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-buckets-overview.html)
88+
- [S3 Directory Buckets API Reference](https://docs.aws.amazon.com/AmazonS3/latest/API/Welcome.html)
89+
- [SDK for PHP S3 Directory Buckets reference](https://docs.aws.amazon.com/aws-sdk-php/v3/api/namespace-Aws.S3-directory-buckets.html)
90+
91+
<!--custom.resources.start-->
92+
<!--custom.resources.end-->
93+
94+
---
95+
96+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
97+
98+
SPDX-License-Identifier: Apache-2.0

php/example_code/s3/S3ExpressBasics.php renamed to php/example_code/s3/express/S3ExpressBasics.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* vendor/bin/phpunit S3ExpressBasicsTests.php
2121
**/
2222

23-
namespace S3;
23+
namespace S3\express;
2424
use Aws\CloudFormation\CloudFormationClient;
2525
use Aws\CloudFormation\Exception\CloudFormationException;
2626
use Aws\Credentials\Credentials;
@@ -31,6 +31,7 @@
3131
use AwsUtilities\RunnableExample;
3232
use Ec2\EC2Service;
3333
use Iam\IAMService;
34+
use S3\S3Service;
3435
use function AwsUtilities\pressEnter;
3536
use function AwsUtilities\testable_readline;
3637

@@ -110,7 +111,7 @@ public function runExample()
110111

111112
$this->cloudFormationClient = new CloudFormationClient([]);
112113
$stackName = "cfn-stack-s3-express-basics-" . uniqid();
113-
$file = file_get_contents(__DIR__ . "/../../../resources/cfn/s3_express_basics/s3_express_template.yml");
114+
$file = file_get_contents(__DIR__ . "/../../../../resources/cfn/s3_express_basics/s3_express_template.yml");
114115
$result = $this->cloudFormationClient->createStack([
115116
'StackName' => $stackName,
116117
'TemplateBody' => $file,
@@ -138,14 +139,10 @@ public function runExample()
138139
$expressUserName = $output['OutputValue'];
139140
}
140141
}
141-
$this->resources['regularUserName'] = $regularUserName;
142-
$this->resources['expressUserName'] = $expressUserName;
143142
$regularKey = $this->iamService->createAccessKey($regularUserName);
144143
$regularCredentials = new Credentials($regularKey['AccessKeyId'], $regularKey['SecretAccessKey']);
145-
$this->resources['regularKey'] = $regularKey['AccessKeyId'];
146144
$expressKey = $this->iamService->createAccessKey($expressUserName);
147145
$expressCredentials = new Credentials($expressKey['AccessKeyId'], $expressKey['SecretAccessKey']);
148-
$this->resources['expressKey'] = $expressKey['AccessKeyId'];
149146

150147
// 3. Create an additional client using the credentials with S3 Express permissions.
151148
echo "\n";

php/example_code/s3/tests/S3ExpressBasicsTest.php renamed to php/example_code/s3/express/tests/S3ExpressBasicsTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@
66
// Integration test runner for S3ExpressBasics.php.
77
//
88

9-
namespace S3\tests;
9+
namespace S3\express\tests;
1010

11-
use Aws\CloudFormation\CloudFormationClient;
1211
use Aws\S3\Exception\S3Exception;
13-
use Aws\S3\S3Client;
1412
use PHPUnit\Framework\TestCase;
15-
use S3\S3ExpressBasics;
16-
use S3\S3Service;
13+
use S3\express\S3ExpressBasics;
1714

1815
/**
1916
* @group integ
20-
* @covers \S3\S3ExpressBasics
17+
* @covers \S3\express\S3ExpressBasics
2118
* @covers \S3\S3Service
2219
*/
2320
class S3ExpressBasicsTest extends TestCase

0 commit comments

Comments
 (0)