createService method
- required String serviceName,
- required SourceConfiguration sourceConfiguration,
- String? autoScalingConfigurationArn,
- EncryptionConfiguration? encryptionConfiguration,
- HealthCheckConfiguration? healthCheckConfiguration,
- InstanceConfiguration? instanceConfiguration,
- NetworkConfiguration? networkConfiguration,
- ServiceObservabilityConfiguration? observabilityConfiguration,
- List<
Tag> ? tags,
Create an App Runner service. After the service is created, the action also automatically starts a deployment.
This is an asynchronous operation. On a successful call, you can use the
returned OperationId and the ListOperations
call to track the operation's progress.
May throw InternalServiceErrorException.
May throw InvalidRequestException.
May throw ServiceQuotaExceededException.
Parameter serviceName :
A name for the App Runner service. It must be unique across all the
running App Runner services in your Amazon Web Services account in the
Amazon Web Services Region.
Parameter sourceConfiguration :
The source to deploy to the App Runner service. It can be a code or an
image repository.
Parameter autoScalingConfigurationArn :
The Amazon Resource Name (ARN) of an App Runner automatic scaling
configuration resource that you want to associate with your service. If
not provided, App Runner associates the latest revision of a default auto
scaling configuration.
Specify an ARN with a name and a revision number to associate that
revision. For example:
arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability/3
Specify just the name to associate the latest revision. For example:
arn:aws:apprunner:us-east-1:123456789012:autoscalingconfiguration/high-availability
Parameter encryptionConfiguration :
An optional custom encryption key that App Runner uses to encrypt the copy
of your source repository that it maintains and your service logs. By
default, App Runner uses an Amazon Web Services managed key.
Parameter healthCheckConfiguration :
The settings for the health check that App Runner performs to monitor the
health of the App Runner service.
Parameter instanceConfiguration :
The runtime configuration of instances (scaling units) of your service.
Parameter networkConfiguration :
Configuration settings related to network traffic of the web application
that the App Runner service runs.
Parameter observabilityConfiguration :
The observability configuration of your service.
Parameter tags :
An optional list of metadata items that you can associate with the App
Runner service resource. A tag is a key-value pair.
Implementation
Future<CreateServiceResponse> createService({
required String serviceName,
required SourceConfiguration sourceConfiguration,
String? autoScalingConfigurationArn,
EncryptionConfiguration? encryptionConfiguration,
HealthCheckConfiguration? healthCheckConfiguration,
InstanceConfiguration? instanceConfiguration,
NetworkConfiguration? networkConfiguration,
ServiceObservabilityConfiguration? observabilityConfiguration,
List<Tag>? tags,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'AppRunner.CreateService'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'ServiceName': serviceName,
'SourceConfiguration': sourceConfiguration,
if (autoScalingConfigurationArn != null)
'AutoScalingConfigurationArn': autoScalingConfigurationArn,
if (encryptionConfiguration != null)
'EncryptionConfiguration': encryptionConfiguration,
if (healthCheckConfiguration != null)
'HealthCheckConfiguration': healthCheckConfiguration,
if (instanceConfiguration != null)
'InstanceConfiguration': instanceConfiguration,
if (networkConfiguration != null)
'NetworkConfiguration': networkConfiguration,
if (observabilityConfiguration != null)
'ObservabilityConfiguration': observabilityConfiguration,
if (tags != null) 'Tags': tags,
},
);
return CreateServiceResponse.fromJson(jsonResponse.body);
}