Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 4dc5119

Browse files
committed
updated a number of procedures
1 parent 96adaf2 commit 4dc5119

14 files changed

Lines changed: 379 additions & 391 deletions

‎doc_source/create-key-pair.rst‎

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,44 @@ key pair when you connect to the instance. You can create a key pair or use an e
1717
that you've used when launching other instances. For more information, see :ec2-ug:`Amazon EC2 Key
1818
Pairs <ec2-key-pairs>` in the |EC2-ug|.
1919

20-
**To create a key pair and save the private key**
20+
.. topic:: To create a key pair and save the private key
2121

22-
1. Create and initialize a :java-api:`CreateKeyPairRequest
23-
<services/ec2/model/CreateKeyPairRequest>` instance. Use the :java-ref:`withKeyName
24-
<com/amazonaws/services/ec2/model/CreateKeyPairRequest.html#withKeyName(java.lang.String)>`
25-
method to set the key pair name, as follows:
22+
#. Create and initialize a :java-api:`CreateKeyPairRequest
23+
<services/ec2/model/CreateKeyPairRequest>` instance. Use the :java-ref:`withKeyName
24+
<com/amazonaws/services/ec2/model/CreateKeyPairRequest.html#withKeyName(java.lang.String)>`
25+
method to set the key pair name, as follows:
2626

27-
.. code-block:: java
27+
.. code-block:: java
2828
29-
CreateKeyPairRequest createKeyPairRequest = new CreateKeyPairRequest();
29+
CreateKeyPairRequest createKeyPairRequest = new CreateKeyPairRequest();
3030
31-
createKeyPairRequest.withKeyName(keyName);
31+
createKeyPairRequest.withKeyName(keyName);
3232
33-
.. important:: Key pair names must be unique. If you attempt to create a key pair with the same
34-
key name as an existing key pair, you'll get an exception.
33+
.. important:: Key pair names must be unique. If you attempt to create a key pair with the
34+
same key name as an existing key pair, you'll get an exception.
3535

36-
2. Pass the request object to the :java-ref:`createKeyPair
37-
<com/amazonaws/services/ec2/AmazonEC2.html#createKeyPair%28com.amazonaws.services.ec2.model.CreateKeyPairRequest%29>`
38-
method. The method returns a :java-api:`CreateKeyPairResult
39-
<services/ec2/model/CreateKeyPairResult>` instance, as follows:
36+
#. Pass the request object to the :java-ref:`createKeyPair
37+
<com/amazonaws/services/ec2/AmazonEC2.html#createKeyPair%28com.amazonaws.services.ec2.model.CreateKeyPairRequest%29>`
38+
method. The method returns a :java-api:`CreateKeyPairResult
39+
<services/ec2/model/CreateKeyPairResult>` instance, as follows:
4040

41-
.. code-block:: java
41+
.. code-block:: java
4242
43-
CreateKeyPairResult createKeyPairResult =
44-
amazonEC2Client.createKeyPair(createKeyPairRequest);
43+
CreateKeyPairResult createKeyPairResult =
44+
amazonEC2Client.createKeyPair(createKeyPairRequest);
4545
46-
3. Call the result object's :java-ref:`getKeyPair
47-
<com/amazonaws/services/ec2/model/CreateKeyPairResult.html#getKeyPair%28%29>` method to obtain a
48-
:java-api:`KeyPair <services/ec2/model/KeyPair>` object. Call the :code:`KeyPair` object's
49-
:java-ref:`getKeyMaterial <com/amazonaws/services/ec2/model/KeyPair.html#getKeyMaterial%28%29>`
50-
method to obtain the unencrypted PEM-encoded private key, as follows:
46+
#. Call the result object's :java-ref:`getKeyPair
47+
<com/amazonaws/services/ec2/model/CreateKeyPairResult.html#getKeyPair%28%29>` method to
48+
obtain a :java-api:`KeyPair <services/ec2/model/KeyPair>` object. Call the :code:`KeyPair`
49+
object's :java-ref:`getKeyMaterial
50+
<com/amazonaws/services/ec2/model/KeyPair.html#getKeyMaterial%28%29>` method to obtain the
51+
unencrypted PEM-encoded private key, as follows:
5152

52-
.. code-block:: java
53+
.. code-block:: java
5354
54-
KeyPair keyPair = new KeyPair();
55+
KeyPair keyPair = new KeyPair();
5556
56-
keyPair = createKeyPairResult.getKeyPair();
57+
keyPair = createKeyPairResult.getKeyPair();
5758
58-
String privateKey = keyPair.getKeyMaterial();
59+
String privateKey = keyPair.getKeyMaterial();
5960

‎doc_source/create-security-group.rst‎

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -26,99 +26,99 @@ EC2-Classic and EC2-VPC, see :ec2-ug:`Supported Platforms <ec2-supported-platfor
2626
For more information about creating a security group using the |EC2| console, see :ec2-ug:`Amazon
2727
EC2 Security Groups <using-network-security>` in the |EC2-ug|.
2828

29-
**To create a security group**
29+
.. topic:: To create a security group
3030

31-
1. Create and initialize a :java-api:`CreateSecurityGroupRequest
32-
<services/ec2/model/CreateSecurityGroupRequest>` instance. Use the :java-ref:`withGroupName
33-
<com/amazonaws/services/ec2/model/CreateSecurityGroupRequest.html#withGroupName(java.lang.String)>`
34-
method to set the security group name, and the :java-ref:`withDescription
35-
<com/amazonaws/services/ec2/model/CreateSecurityGroupRequest.html#withDescription(java.lang.String)>`
36-
method to set the security group description, as follows:
31+
#. Create and initialize a :java-api:`CreateSecurityGroupRequest
32+
<services/ec2/model/CreateSecurityGroupRequest>` instance. Use the :java-ref:`withGroupName
33+
<com/amazonaws/services/ec2/model/CreateSecurityGroupRequest.html#withGroupName(java.lang.String)>`
34+
method to set the security group name, and the :java-ref:`withDescription
35+
<com/amazonaws/services/ec2/model/CreateSecurityGroupRequest.html#withDescription(java.lang.String)>`
36+
method to set the security group description, as follows:
3737

38-
.. code-block:: java
38+
.. code-block:: java
3939
40-
CreateSecurityGroupRequest csgr = new CreateSecurityGroupRequest();
40+
CreateSecurityGroupRequest csgr = new CreateSecurityGroupRequest();
4141
42-
csgr.withGroupName("JavaSecurityGroup").withDescription("My security group");
42+
csgr.withGroupName("JavaSecurityGroup").withDescription("My security group");
4343
44-
The security group name must be unique within the AWS region in which you initialize your |EC2|
45-
client. You must use US-ASCII characters for the security group name and description.
44+
The security group name must be unique within the AWS region in which you initialize your |EC2|
45+
client. You must use US-ASCII characters for the security group name and description.
4646

47-
2. Pass the request object as a parameter to the :java-ref:`createSecurityGroup
48-
<com/amazonaws/services/ec2/AmazonEC2.html#createSecurityGroup%28com.amazonaws.services.ec2.model.CreateSecurityGroupRequest%29>`
49-
method. The method returns a :java-api:`CreateSecurityGroupResult
50-
<services/ec2/model/CreateSecurityGroupResult>` object, as follows:
47+
#. Pass the request object as a parameter to the :java-ref:`createSecurityGroup
48+
<com/amazonaws/services/ec2/AmazonEC2.html#createSecurityGroup%28com.amazonaws.services.ec2.model.CreateSecurityGroupRequest%29>`
49+
method. The method returns a :java-api:`CreateSecurityGroupResult
50+
<services/ec2/model/CreateSecurityGroupResult>` object, as follows:
5151

52-
.. code-block:: java
52+
.. code-block:: java
5353
54-
CreateSecurityGroupResult createSecurityGroupResult =
55-
amazonEC2Client.createSecurityGroup(createSecurityGroupRequest);
54+
CreateSecurityGroupResult createSecurityGroupResult =
55+
amazonEC2Client.createSecurityGroup(createSecurityGroupRequest);
5656
57-
If you attempt to create a security group with the same name as an existing security group,
58-
:code:`createSecurityGroup` throws an exception.
57+
If you attempt to create a security group with the same name as an existing security group,
58+
:code:`createSecurityGroup` throws an exception.
5959

6060
By default, a new security group does not allow any inbound traffic to your |EC2| instance. To allow
6161
inbound traffic, you must explicitly authorize security group ingress. You can authorize ingress for
6262
individual IP addresses, for a range of IP addresses, for a specific protocol, and for TCP/UDP
6363
ports.
6464

65-
**To authorize security group ingress**
65+
.. topic:: To authorize security group ingress
6666

67-
1. Create and initialize an :java-api:`IpPermission <services/ec2/model/IpPermission>` instance.
68-
Use the :java-ref:`withIpRanges
69-
<com/amazonaws/services/ec2/model/IpPermission.html#withIpRanges(java.lang.String...)>` method
70-
to set the range of IP addresses to authorize ingress for, and use the :java-ref:`withIpProtocol
71-
<com/amazonaws/services/ec2/model/IpPermission.html#withIpProtocol(java.lang.String)>` method to
72-
set the IP protocol. Use the :java-ref:`withFromPort
73-
<com/amazonaws/services/ec2/model/IpPermission.html#withFromPort(java.lang.Integer)>` and
74-
:java-ref:`withToPort
75-
<com/amazonaws/services/ec2/model/IpPermission.html#withToPort(java.lang.Integer)>` methods to
76-
specify range of ports to authorize ingress for, as follows:
67+
#. Create and initialize an :java-api:`IpPermission <services/ec2/model/IpPermission>` instance.
68+
Use the :java-ref:`withIpRanges
69+
<com/amazonaws/services/ec2/model/IpPermission.html#withIpRanges(java.lang.String...)>` method
70+
to set the range of IP addresses to authorize ingress for, and use the :java-ref:`withIpProtocol
71+
<com/amazonaws/services/ec2/model/IpPermission.html#withIpProtocol(java.lang.String)>` method to
72+
set the IP protocol. Use the :java-ref:`withFromPort
73+
<com/amazonaws/services/ec2/model/IpPermission.html#withFromPort(java.lang.Integer)>` and
74+
:java-ref:`withToPort
75+
<com/amazonaws/services/ec2/model/IpPermission.html#withToPort(java.lang.Integer)>` methods to
76+
specify range of ports to authorize ingress for, as follows:
7777

78-
.. code-block:: java
78+
.. code-block:: java
7979
80-
IpPermission ipPermission =
81-
new IpPermission();
80+
IpPermission ipPermission =
81+
new IpPermission();
8282
83-
ipPermission.withIpRanges("111.111.111.111/32", "150.150.150.150/32")
84-
.withIpProtocol("tcp")
85-
.withFromPort(22)
86-
.withToPort(22);
83+
ipPermission.withIpRanges("111.111.111.111/32", "150.150.150.150/32")
84+
.withIpProtocol("tcp")
85+
.withFromPort(22)
86+
.withToPort(22);
8787
88-
All the conditions that you specify in the :code:`IpPermission` object must be met in order for
89-
ingress to be allowed.
88+
All the conditions that you specify in the :code:`IpPermission` object must be met in order for
89+
ingress to be allowed.
9090

91-
Specify the IP address using CIDR notation. If you specify the protocol as TCP/UDP, you must
92-
provide a source port and a destination port. You can authorize ports only if you specify TCP or
93-
UDP.
91+
Specify the IP address using CIDR notation. If you specify the protocol as TCP/UDP, you must
92+
provide a source port and a destination port. You can authorize ports only if you specify TCP or
93+
UDP.
9494

95-
2. Create and initialize an :java-api:`AuthorizeSecurityGroupIngressRequest
96-
<services/ec2/model/AuthorizeSecurityGroupEgressRequest>` instance. Use the
97-
:code:`withGroupName` method to specify the security group name, and pass the
98-
:code:`IpPermission` object you initialized earlier to the :java-ref:`withIpPermissions
99-
<com/amazonaws/services/ec2/model/AuthorizeSecurityGroupEgressRequest.html#withIpPermissions(com.amazonaws.services.ec2.model.IpPermission...)>`
100-
method, as follows:
95+
#. Create and initialize an :java-api:`AuthorizeSecurityGroupIngressRequest
96+
<services/ec2/model/AuthorizeSecurityGroupEgressRequest>` instance. Use the
97+
:code:`withGroupName` method to specify the security group name, and pass the
98+
:code:`IpPermission` object you initialized earlier to the :java-ref:`withIpPermissions
99+
<com/amazonaws/services/ec2/model/AuthorizeSecurityGroupEgressRequest.html#withIpPermissions(com.amazonaws.services.ec2.model.IpPermission...)>`
100+
method, as follows:
101101

102-
.. code-block:: java
102+
.. code-block:: java
103103
104-
AuthorizeSecurityGroupIngressRequest authorizeSecurityGroupIngressRequest =
105-
new AuthorizeSecurityGroupIngressRequest();
104+
AuthorizeSecurityGroupIngressRequest authorizeSecurityGroupIngressRequest =
105+
new AuthorizeSecurityGroupIngressRequest();
106106
107-
authorizeSecurityGroupIngressRequest.withGroupName("JavaSecurityGroup")
108-
.withIpPermissions(ipPermission);
107+
authorizeSecurityGroupIngressRequest.withGroupName("JavaSecurityGroup")
108+
.withIpPermissions(ipPermission);
109109
110-
3. Pass the request object into the :java-ref:`authorizeSecurityGroupIngress
111-
<com/amazonaws/services/ec2/AmazonEC2.html#authorizeSecurityGroupEgress%28com.amazonaws.services.ec2.model.AuthorizeSecurityGroupEgressRequest%29>`
112-
method, as follows:
110+
#. Pass the request object into the :java-ref:`authorizeSecurityGroupIngress
111+
<com/amazonaws/services/ec2/AmazonEC2.html#authorizeSecurityGroupEgress%28com.amazonaws.services.ec2.model.AuthorizeSecurityGroupEgressRequest%29>`
112+
method, as follows:
113113

114-
.. code-block:: java
114+
.. code-block:: java
115115
116-
amazonEC2Client.authorizeSecurityGroupIngress(authorizeSecurityGroupIngressRequest);
116+
amazonEC2Client.authorizeSecurityGroupIngress(authorizeSecurityGroupIngressRequest);
117117
118-
If you call :code:`authorizeSecurityGroupIngress` with IP addresses for which ingress is already
119-
authorized, the method throws an exception. Create and initialize a new :code:`IpPermission`
120-
object to authorize ingress for different IPs, ports, and protocols before calling
121-
:code:`AuthorizeSecurityGroupIngress`.
118+
If you call :code:`authorizeSecurityGroupIngress` with IP addresses for which ingress is already
119+
authorized, the method throws an exception. Create and initialize a new :code:`IpPermission`
120+
object to authorize ingress for different IPs, ports, and protocols before calling
121+
:code:`AuthorizeSecurityGroupIngress`.
122122

123123
Whenever you call the :code:`authorizeSecurityGroupIngress` or
124124
:java-ref:`authorizeSecurityGroupEgress

‎doc_source/creating-clients.rst‎

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -82,57 +82,60 @@ Creating Async Clients
8282
The |sdk-java| also has asynchronous (or async) clients for every service, except for |S3long|. There is also a corresponding async
8383
client builder for every service.
8484
85-
**To create an async |DDB| client with the default ExecutorService**
85+
.. topic:: To create an async |DDB| client with the default ExecutorService
8686
87-
.. code-block:: java
87+
.. code-block:: java
8888
89-
AmazonDynamoDBAsync ddbAsync = AmazonDynamoDBAsyncClientBuilder.standard()
90-
.withRegion(Regions.US_WEST_2)
91-
.withCredentials(new ProfileCredentialsProvider("myProfile"))
92-
.build();
89+
AmazonDynamoDBAsync ddbAsync = AmazonDynamoDBAsyncClientBuilder.standard()
90+
.withRegion(Regions.US_WEST_2)
91+
.withCredentials(new ProfileCredentialsProvider("myProfile"))
92+
.build();
9393
94-
In addition to the configuration options that the synchronous (or sync) client builder supports,
95-
the async client allows you to set a custom :java-api:`ExecutorFactory <client/builder/ExecutorFactory>`
96-
to change the ``ExecutorService`` that the async client uses. ``ExecutorFactory`` is a functional
97-
interface, so it interoperates with Java 8 lambda expressions and method references.
94+
In addition to the configuration options that the synchronous (or sync) client builder supports, the
95+
async client allows you to set a custom :java-api:`ExecutorFactory <client/builder/ExecutorFactory>`
96+
to change the :classname:`ExecutorService` that the async client uses. :classname:`ExecutorFactory`
97+
is a functional interface, so it interoperates with Java 8 lambda expressions and method references.
9898
99-
**To create an async client with a custom executor**
99+
.. topic:: To create an async client with a custom executor
100100
101-
.. code-block:: java
101+
.. code-block:: java
102+
103+
AmazonDynamoDBAsync ddbAsync = AmazonDynamoDBAsyncClientBuilder.standard()
104+
.withExecutorFactory(() -> Executors.newFixedThreadPool(10))
105+
.build();
102106
103-
AmazonDynamoDBAsync ddbAsync = AmazonDynamoDBAsyncClientBuilder.standard()
104-
.withExecutorFactory(() -> Executors.newFixedThreadPool(10))
105-
.build();
106107
107108
Default Client
108109
==============
109110
110-
Both the sync and async client builders have another factory method called ``defaultClient``. This
111-
method creates a service client with the default configuration, using the default provider chain to
112-
load credentials and the AWS region. If either credentials or the region cannot be determined from
113-
the environment that the application is running in, the call to ``defaultClient`` will fail. See
114-
:doc:`credentials` and :doc:`java-dg-region-selection` for more information on how credentials and
115-
region are determined.
111+
Both the sync and async client builders have another factory method called
112+
:methodname:`defaultClient`. This method creates a service client with the default configuration,
113+
using the default provider chain to load credentials and the AWS region. If either credentials or
114+
the region cannot be determined from the environment that the application is running in, the call to
115+
:methodname:`defaultClient` will fail. See :doc:`credentials` and :doc:`java-dg-region-selection`
116+
for more information on how credentials and region are determined.
116117
117-
**To create a default service client**
118+
.. topic:: To create a default service client
118119
119-
.. code-block:: java
120+
.. code-block:: java
121+
122+
AmazonDynamoDB ddb = AmazonDynamoDBClientBuilder.defaultClient();
120123
121-
AmazonDynamoDB ddb = AmazonDynamoDBClientBuilder.defaultClient();
122124
123125
Client Lifecycle
124126
================
125127
126128
Service clients in the SDK are thread-safe and, for best performance, you should treat them as
127-
long-lived objects. Each client has its own connection pool resource that is shut down when the
128-
client is garbage collected. To explicitly shut down a client, you can call the ``shutdown``
129-
method. After calling ``shutdown``, all client resources are released and the client is unusable.
129+
long-lived objects. Each client has its own connection pool resource that is shut down when the
130+
client is garbage collected. To explicitly shut down a client, you can call the
131+
:methodname:`shutdown` method. After calling :methodname:`shutdown`, all client resources are
132+
released and the client is unusable.
130133
131-
**To shut down a client**
134+
.. topic:: To shut down a client
132135
133-
.. code-block:: java
136+
.. code-block:: java
134137
135-
AmazonDynamoDB ddb = AmazonDynamoDBClientBuilder.defaultClient();
136-
ddb.shutdown();
137-
// Client is now unusable
138+
AmazonDynamoDB ddb = AmazonDynamoDBClientBuilder.defaultClient();
139+
ddb.shutdown();
140+
// Client is now unusable
138141

0 commit comments

Comments
 (0)