Skip to content

Commit b36c500

Browse files
author
awstools
committed
feat(client-cloudfront): Adds support for CloudFront origin access control (OAC), making it possible to restrict public access to S3 bucket origins in all AWS Regions, those with SSE-KMS, and more.
1 parent dcfda0d commit b36c500

19 files changed

+3596
-398
lines changed

clients/client-cloudfront/src/CloudFront.ts

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ import {
5757
CreateMonitoringSubscriptionCommandInput,
5858
CreateMonitoringSubscriptionCommandOutput,
5959
} from "./commands/CreateMonitoringSubscriptionCommand";
60+
import {
61+
CreateOriginAccessControlCommand,
62+
CreateOriginAccessControlCommandInput,
63+
CreateOriginAccessControlCommandOutput,
64+
} from "./commands/CreateOriginAccessControlCommand";
6065
import {
6166
CreateOriginRequestPolicyCommand,
6267
CreateOriginRequestPolicyCommandInput,
@@ -127,6 +132,11 @@ import {
127132
DeleteMonitoringSubscriptionCommandInput,
128133
DeleteMonitoringSubscriptionCommandOutput,
129134
} from "./commands/DeleteMonitoringSubscriptionCommand";
135+
import {
136+
DeleteOriginAccessControlCommand,
137+
DeleteOriginAccessControlCommandInput,
138+
DeleteOriginAccessControlCommandOutput,
139+
} from "./commands/DeleteOriginAccessControlCommand";
130140
import {
131141
DeleteOriginRequestPolicyCommand,
132142
DeleteOriginRequestPolicyCommandInput,
@@ -224,6 +234,16 @@ import {
224234
GetMonitoringSubscriptionCommandInput,
225235
GetMonitoringSubscriptionCommandOutput,
226236
} from "./commands/GetMonitoringSubscriptionCommand";
237+
import {
238+
GetOriginAccessControlCommand,
239+
GetOriginAccessControlCommandInput,
240+
GetOriginAccessControlCommandOutput,
241+
} from "./commands/GetOriginAccessControlCommand";
242+
import {
243+
GetOriginAccessControlConfigCommand,
244+
GetOriginAccessControlConfigCommandInput,
245+
GetOriginAccessControlConfigCommandOutput,
246+
} from "./commands/GetOriginAccessControlConfigCommand";
227247
import {
228248
GetOriginRequestPolicyCommand,
229249
GetOriginRequestPolicyCommandInput,
@@ -344,6 +364,11 @@ import {
344364
ListKeyGroupsCommandInput,
345365
ListKeyGroupsCommandOutput,
346366
} from "./commands/ListKeyGroupsCommand";
367+
import {
368+
ListOriginAccessControlsCommand,
369+
ListOriginAccessControlsCommandInput,
370+
ListOriginAccessControlsCommandOutput,
371+
} from "./commands/ListOriginAccessControlsCommand";
347372
import {
348373
ListOriginRequestPoliciesCommand,
349374
ListOriginRequestPoliciesCommandInput,
@@ -425,6 +450,11 @@ import {
425450
UpdateKeyGroupCommandInput,
426451
UpdateKeyGroupCommandOutput,
427452
} from "./commands/UpdateKeyGroupCommand";
453+
import {
454+
UpdateOriginAccessControlCommand,
455+
UpdateOriginAccessControlCommandInput,
456+
UpdateOriginAccessControlCommandOutput,
457+
} from "./commands/UpdateOriginAccessControlCommand";
428458
import {
429459
UpdateOriginRequestPolicyCommand,
430460
UpdateOriginRequestPolicyCommandInput,
@@ -875,6 +905,44 @@ export class CloudFront extends CloudFrontClient {
875905
}
876906
}
877907

908+
/**
909+
* <p>Creates a new origin access control in CloudFront. After you create an origin access control, you
910+
* can add it to an origin in a CloudFront distribution so that CloudFront sends authenticated (signed)
911+
* requests to the origin.</p>
912+
* <p>For an Amazon S3 origin, this makes it possible to block public access to the Amazon S3 bucket
913+
* so that viewers (users) can access the content in the bucket only through CloudFront.</p>
914+
* <p>For more information about using a CloudFront origin access control, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html">Restricting access to an Amazon S3 origin</a> in the
915+
* <i>Amazon CloudFront Developer Guide</i>.</p>
916+
*/
917+
public createOriginAccessControl(
918+
args: CreateOriginAccessControlCommandInput,
919+
options?: __HttpHandlerOptions
920+
): Promise<CreateOriginAccessControlCommandOutput>;
921+
public createOriginAccessControl(
922+
args: CreateOriginAccessControlCommandInput,
923+
cb: (err: any, data?: CreateOriginAccessControlCommandOutput) => void
924+
): void;
925+
public createOriginAccessControl(
926+
args: CreateOriginAccessControlCommandInput,
927+
options: __HttpHandlerOptions,
928+
cb: (err: any, data?: CreateOriginAccessControlCommandOutput) => void
929+
): void;
930+
public createOriginAccessControl(
931+
args: CreateOriginAccessControlCommandInput,
932+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: CreateOriginAccessControlCommandOutput) => void),
933+
cb?: (err: any, data?: CreateOriginAccessControlCommandOutput) => void
934+
): Promise<CreateOriginAccessControlCommandOutput> | void {
935+
const command = new CreateOriginAccessControlCommand(args);
936+
if (typeof optionsOrCb === "function") {
937+
this.send(command, optionsOrCb);
938+
} else if (typeof cb === "function") {
939+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
940+
this.send(command, optionsOrCb || {}, cb);
941+
} else {
942+
return this.send(command, optionsOrCb);
943+
}
944+
}
945+
878946
/**
879947
* <p>Creates an origin request policy.</p>
880948
* <p>After you create an origin request policy, you can attach it to one or more cache behaviors.
@@ -1379,6 +1447,41 @@ export class CloudFront extends CloudFrontClient {
13791447
}
13801448
}
13811449

1450+
/**
1451+
* <p>Deletes a CloudFront origin access control.</p>
1452+
* <p>You cannot delete an origin access control if it's in use. First, update all distributions
1453+
* to remove the origin access control from all origins, then delete the origin access
1454+
* control.</p>
1455+
*/
1456+
public deleteOriginAccessControl(
1457+
args: DeleteOriginAccessControlCommandInput,
1458+
options?: __HttpHandlerOptions
1459+
): Promise<DeleteOriginAccessControlCommandOutput>;
1460+
public deleteOriginAccessControl(
1461+
args: DeleteOriginAccessControlCommandInput,
1462+
cb: (err: any, data?: DeleteOriginAccessControlCommandOutput) => void
1463+
): void;
1464+
public deleteOriginAccessControl(
1465+
args: DeleteOriginAccessControlCommandInput,
1466+
options: __HttpHandlerOptions,
1467+
cb: (err: any, data?: DeleteOriginAccessControlCommandOutput) => void
1468+
): void;
1469+
public deleteOriginAccessControl(
1470+
args: DeleteOriginAccessControlCommandInput,
1471+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: DeleteOriginAccessControlCommandOutput) => void),
1472+
cb?: (err: any, data?: DeleteOriginAccessControlCommandOutput) => void
1473+
): Promise<DeleteOriginAccessControlCommandOutput> | void {
1474+
const command = new DeleteOriginAccessControlCommand(args);
1475+
if (typeof optionsOrCb === "function") {
1476+
this.send(command, optionsOrCb);
1477+
} else if (typeof cb === "function") {
1478+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
1479+
this.send(command, optionsOrCb || {}, cb);
1480+
} else {
1481+
return this.send(command, optionsOrCb);
1482+
}
1483+
}
1484+
13821485
/**
13831486
* <p>Deletes an origin request policy.</p>
13841487
* <p>You cannot delete an origin request policy if it’s attached to any cache behaviors. First
@@ -2142,6 +2245,70 @@ export class CloudFront extends CloudFrontClient {
21422245
}
21432246
}
21442247

2248+
/**
2249+
* <p>Gets a CloudFront origin access control.</p>
2250+
*/
2251+
public getOriginAccessControl(
2252+
args: GetOriginAccessControlCommandInput,
2253+
options?: __HttpHandlerOptions
2254+
): Promise<GetOriginAccessControlCommandOutput>;
2255+
public getOriginAccessControl(
2256+
args: GetOriginAccessControlCommandInput,
2257+
cb: (err: any, data?: GetOriginAccessControlCommandOutput) => void
2258+
): void;
2259+
public getOriginAccessControl(
2260+
args: GetOriginAccessControlCommandInput,
2261+
options: __HttpHandlerOptions,
2262+
cb: (err: any, data?: GetOriginAccessControlCommandOutput) => void
2263+
): void;
2264+
public getOriginAccessControl(
2265+
args: GetOriginAccessControlCommandInput,
2266+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: GetOriginAccessControlCommandOutput) => void),
2267+
cb?: (err: any, data?: GetOriginAccessControlCommandOutput) => void
2268+
): Promise<GetOriginAccessControlCommandOutput> | void {
2269+
const command = new GetOriginAccessControlCommand(args);
2270+
if (typeof optionsOrCb === "function") {
2271+
this.send(command, optionsOrCb);
2272+
} else if (typeof cb === "function") {
2273+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
2274+
this.send(command, optionsOrCb || {}, cb);
2275+
} else {
2276+
return this.send(command, optionsOrCb);
2277+
}
2278+
}
2279+
2280+
/**
2281+
* <p>Gets a CloudFront origin access control.</p>
2282+
*/
2283+
public getOriginAccessControlConfig(
2284+
args: GetOriginAccessControlConfigCommandInput,
2285+
options?: __HttpHandlerOptions
2286+
): Promise<GetOriginAccessControlConfigCommandOutput>;
2287+
public getOriginAccessControlConfig(
2288+
args: GetOriginAccessControlConfigCommandInput,
2289+
cb: (err: any, data?: GetOriginAccessControlConfigCommandOutput) => void
2290+
): void;
2291+
public getOriginAccessControlConfig(
2292+
args: GetOriginAccessControlConfigCommandInput,
2293+
options: __HttpHandlerOptions,
2294+
cb: (err: any, data?: GetOriginAccessControlConfigCommandOutput) => void
2295+
): void;
2296+
public getOriginAccessControlConfig(
2297+
args: GetOriginAccessControlConfigCommandInput,
2298+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: GetOriginAccessControlConfigCommandOutput) => void),
2299+
cb?: (err: any, data?: GetOriginAccessControlConfigCommandOutput) => void
2300+
): Promise<GetOriginAccessControlConfigCommandOutput> | void {
2301+
const command = new GetOriginAccessControlConfigCommand(args);
2302+
if (typeof optionsOrCb === "function") {
2303+
this.send(command, optionsOrCb);
2304+
} else if (typeof cb === "function") {
2305+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
2306+
this.send(command, optionsOrCb || {}, cb);
2307+
} else {
2308+
return this.send(command, optionsOrCb);
2309+
}
2310+
}
2311+
21452312
/**
21462313
* <p>Gets an origin request policy, including the following metadata:</p>
21472314
* <ul>
@@ -3020,6 +3187,43 @@ export class CloudFront extends CloudFrontClient {
30203187
}
30213188
}
30223189

3190+
/**
3191+
* <p>Gets the list of CloudFront origin access controls in this Amazon Web Services account.</p>
3192+
* <p>You can optionally specify the maximum number of items to receive in the response. If the
3193+
* total number of items in the list exceeds the maximum that you specify, or the default
3194+
* maximum, the response is paginated. To get the next page of items, send another request
3195+
* that specifies the <code>NextMarker</code> value from the current response as the
3196+
* <code>Marker</code> value in the next request.</p>
3197+
*/
3198+
public listOriginAccessControls(
3199+
args: ListOriginAccessControlsCommandInput,
3200+
options?: __HttpHandlerOptions
3201+
): Promise<ListOriginAccessControlsCommandOutput>;
3202+
public listOriginAccessControls(
3203+
args: ListOriginAccessControlsCommandInput,
3204+
cb: (err: any, data?: ListOriginAccessControlsCommandOutput) => void
3205+
): void;
3206+
public listOriginAccessControls(
3207+
args: ListOriginAccessControlsCommandInput,
3208+
options: __HttpHandlerOptions,
3209+
cb: (err: any, data?: ListOriginAccessControlsCommandOutput) => void
3210+
): void;
3211+
public listOriginAccessControls(
3212+
args: ListOriginAccessControlsCommandInput,
3213+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: ListOriginAccessControlsCommandOutput) => void),
3214+
cb?: (err: any, data?: ListOriginAccessControlsCommandOutput) => void
3215+
): Promise<ListOriginAccessControlsCommandOutput> | void {
3216+
const command = new ListOriginAccessControlsCommand(args);
3217+
if (typeof optionsOrCb === "function") {
3218+
this.send(command, optionsOrCb);
3219+
} else if (typeof cb === "function") {
3220+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
3221+
this.send(command, optionsOrCb || {}, cb);
3222+
} else {
3223+
return this.send(command, optionsOrCb);
3224+
}
3225+
}
3226+
30233227
/**
30243228
* <p>Gets a list of origin request policies.</p>
30253229
* <p>You can optionally apply a filter to return only the managed policies created by Amazon Web Services, or
@@ -3708,6 +3912,38 @@ export class CloudFront extends CloudFrontClient {
37083912
}
37093913
}
37103914

3915+
/**
3916+
* <p>Updates a CloudFront origin access control.</p>
3917+
*/
3918+
public updateOriginAccessControl(
3919+
args: UpdateOriginAccessControlCommandInput,
3920+
options?: __HttpHandlerOptions
3921+
): Promise<UpdateOriginAccessControlCommandOutput>;
3922+
public updateOriginAccessControl(
3923+
args: UpdateOriginAccessControlCommandInput,
3924+
cb: (err: any, data?: UpdateOriginAccessControlCommandOutput) => void
3925+
): void;
3926+
public updateOriginAccessControl(
3927+
args: UpdateOriginAccessControlCommandInput,
3928+
options: __HttpHandlerOptions,
3929+
cb: (err: any, data?: UpdateOriginAccessControlCommandOutput) => void
3930+
): void;
3931+
public updateOriginAccessControl(
3932+
args: UpdateOriginAccessControlCommandInput,
3933+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: UpdateOriginAccessControlCommandOutput) => void),
3934+
cb?: (err: any, data?: UpdateOriginAccessControlCommandOutput) => void
3935+
): Promise<UpdateOriginAccessControlCommandOutput> | void {
3936+
const command = new UpdateOriginAccessControlCommand(args);
3937+
if (typeof optionsOrCb === "function") {
3938+
this.send(command, optionsOrCb);
3939+
} else if (typeof cb === "function") {
3940+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
3941+
this.send(command, optionsOrCb || {}, cb);
3942+
} else {
3943+
return this.send(command, optionsOrCb);
3944+
}
3945+
}
3946+
37113947
/**
37123948
* <p>Updates an origin request policy configuration.</p>
37133949
* <p>When you update an origin request policy configuration, all the fields are updated

0 commit comments

Comments
 (0)