createFunction method
Creates a CloudFront function.
To create a function, you provide the function code and some configuration information about the function. The response contains an Amazon Resource Name (ARN) that uniquely identifies the function.
When you create a function, it's in the DEVELOPMENT stage. In
this stage, you can test the function with TestFunction, and
update it with UpdateFunction.
When you're ready to use your function with a CloudFront distribution, use
PublishFunction to copy the function from the
DEVELOPMENT stage to LIVE. When it's live, you
can attach the function to a distribution's cache behavior, using the
function's ARN.
May throw FunctionAlreadyExists.
May throw FunctionSizeLimitExceeded.
May throw InvalidArgument.
May throw TooManyFunctions.
May throw UnsupportedOperation.
Parameter functionCode :
The function code. For more information about writing a CloudFront
function, see Writing
function code for CloudFront Functions in the Amazon CloudFront
Developer Guide.
Parameter functionConfig :
Configuration information about the function, including an optional
comment and the function's runtime.
Parameter name :
A name to identify the function.
Implementation
Future<CreateFunctionResult> createFunction({
required Uint8List functionCode,
required FunctionConfig functionConfig,
required String name,
Tags? tags,
}) async {
final $result = await _protocol.sendRaw(
method: 'POST',
requestUri: '/2020-05-31/function',
payload: CreateFunctionRequest(
functionCode: functionCode,
functionConfig: functionConfig,
name: name,
tags: tags)
.toXml('CreateFunctionRequest'),
exceptionFnMap: _exceptionFns,
);
final $elem = await _s.xmlFromResponse($result);
return CreateFunctionResult(
functionSummary: FunctionSummary.fromXml($elem),
eTag: _s.extractHeaderStringValue($result.headers, 'ETag'),
location: _s.extractHeaderStringValue($result.headers, 'Location'),
);
}