createEnvironmentEC2 method
Creates an AWS Cloud9 development environment, launches an Amazon Elastic Compute Cloud (Amazon EC2) instance, and then connects from the instance to the environment.
May throw BadRequestException. May throw ConflictException. May throw NotFoundException. May throw ForbiddenException. May throw TooManyRequestsException. May throw LimitExceededException. May throw InternalServerErrorException.
Parameter instanceType
:
The type of instance to connect to the environment (for example,
t2.micro
).
Parameter name
:
The name of the environment to create.
This name is visible to other AWS IAM users in the same AWS account.
Parameter automaticStopTimeMinutes
:
The number of minutes until the running instance is shut down after the
environment has last been used.
Parameter clientRequestToken
:
A unique, case-sensitive string that helps AWS Cloud9 to ensure this
operation completes no more than one time.
For more information, see Client Tokens in the Amazon EC2 API Reference.
Parameter connectionType
:
The connection type used for connecting to an Amazon EC2 environment.
Parameter description
:
The description of the environment to create.
Parameter ownerArn
:
The Amazon Resource Name (ARN) of the environment owner. This ARN can be
the ARN of any AWS IAM principal. If this value is not specified, the ARN
defaults to this environment's creator.
Parameter subnetId
:
The ID of the subnet in Amazon VPC that AWS Cloud9 will use to communicate
with the Amazon EC2 instance.
Parameter tags
:
An array of key-value pairs that will be associated with the new AWS
Cloud9 development environment.
Implementation
Future<CreateEnvironmentEC2Result> createEnvironmentEC2({
required String instanceType,
required String name,
int? automaticStopTimeMinutes,
String? clientRequestToken,
ConnectionType? connectionType,
String? description,
String? ownerArn,
String? subnetId,
List<Tag>? tags,
}) async {
ArgumentError.checkNotNull(instanceType, 'instanceType');
_s.validateStringLength(
'instanceType',
instanceType,
5,
20,
isRequired: true,
);
ArgumentError.checkNotNull(name, 'name');
_s.validateStringLength(
'name',
name,
1,
60,
isRequired: true,
);
_s.validateNumRange(
'automaticStopTimeMinutes',
automaticStopTimeMinutes,
0,
20160,
);
_s.validateStringLength(
'description',
description,
0,
200,
);
_s.validateStringLength(
'subnetId',
subnetId,
5,
30,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AWSCloud9WorkspaceManagementService.CreateEnvironmentEC2'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'instanceType': instanceType,
'name': name,
if (automaticStopTimeMinutes != null)
'automaticStopTimeMinutes': automaticStopTimeMinutes,
if (clientRequestToken != null)
'clientRequestToken': clientRequestToken,
if (connectionType != null) 'connectionType': connectionType.toValue(),
if (description != null) 'description': description,
if (ownerArn != null) 'ownerArn': ownerArn,
if (subnetId != null) 'subnetId': subnetId,
if (tags != null) 'tags': tags,
},
);
return CreateEnvironmentEC2Result.fromJson(jsonResponse.body);
}