createOriginAccessControl method

Future<CreateOriginAccessControlResult> createOriginAccessControl({
  1. required OriginAccessControlConfig originAccessControlConfig,
})

Creates a new origin access control in CloudFront. After you create an origin access control, you can add it to an origin in a CloudFront distribution so that CloudFront sends authenticated (signed) requests to the origin.

This makes it possible to block public access to the origin, allowing viewers (users) to access the origin's content only through CloudFront.

For more information about using a CloudFront origin access control, see Restricting access to an Amazon Web Services origin in the Amazon CloudFront Developer Guide.

May throw InvalidArgument. May throw OriginAccessControlAlreadyExists. May throw TooManyOriginAccessControls.

Parameter originAccessControlConfig : Contains the origin access control.

Implementation

Future<CreateOriginAccessControlResult> createOriginAccessControl({
  required OriginAccessControlConfig originAccessControlConfig,
}) async {
  final $result = await _protocol.sendRaw(
    method: 'POST',
    requestUri: '/2020-05-31/origin-access-control',
    payload: originAccessControlConfig.toXml('OriginAccessControlConfig'),
    exceptionFnMap: _exceptionFns,
  );
  final $elem = await _s.xmlFromResponse($result);
  return CreateOriginAccessControlResult(
    originAccessControl: OriginAccessControl.fromXml($elem),
    eTag: _s.extractHeaderStringValue($result.headers, 'ETag'),
    location: _s.extractHeaderStringValue($result.headers, 'Location'),
  );
}