@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
137 lines • 5.71 kB
JavaScript
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.OriginAccessIdentity = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Creates an Amazon CloudFront origin access identity.
*
* For information about CloudFront distributions, see the
* [Amazon CloudFront Developer Guide](http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html). For more information on generating
* origin access identities, see
* [Using an Origin Access Identity to Restrict Access to Your Amazon S3 Content][2].
*
* ## Example Usage
*
* The following example below creates a CloudFront origin access identity.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.cloudfront.OriginAccessIdentity("example", {comment: "Some comment"});
* ```
*
* ## Using With CloudFront
*
* Normally, when referencing an origin access identity in CloudFront, you need to
* prefix the ID with the `origin-access-identity/cloudfront/` special path.
* The `cloudfrontAccessIdentityPath` allows this to be circumvented.
* The below snippet demonstrates use with the `s3OriginConfig` structure for the
* `aws.cloudfront.Distribution` resource:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.cloudfront.Distribution("example", {origins: [{
* s3OriginConfig: {
* originAccessIdentity: exampleAwsCloudfrontOriginAccessIdentity.cloudfrontAccessIdentityPath,
* },
* }]});
* ```
*
* ### Updating your bucket policy
*
* Note that the AWS API may translate the `s3CanonicalUserId` `CanonicalUser`
* principal into an `AWS` IAM ARN principal when supplied in an
* `aws.s3.Bucket` bucket policy, causing spurious diffs. If
* you see this behavior, use the `iamArn` instead:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const s3Policy = aws.iam.getPolicyDocument({
* statements: [{
* actions: ["s3:GetObject"],
* resources: [`${exampleAwsS3Bucket.arn}/*`],
* principals: [{
* type: "AWS",
* identifiers: [exampleAwsCloudfrontOriginAccessIdentity.iamArn],
* }],
* }],
* });
* const example = new aws.s3.BucketPolicy("example", {
* bucket: exampleAwsS3Bucket.id,
* policy: s3Policy.then(s3Policy => s3Policy.json),
* });
* ```
*
* [1]: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html
* [2]: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html
*
* ## Import
*
* Using `pulumi import`, import Cloudfront Origin Access Identities using the `id`. For example:
*
* ```sh
* $ pulumi import aws:cloudfront/originAccessIdentity:OriginAccessIdentity origin_access E74FTE3AEXAMPLE
* ```
*/
class OriginAccessIdentity extends pulumi.CustomResource {
/**
* Get an existing OriginAccessIdentity resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new OriginAccessIdentity(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of OriginAccessIdentity. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === OriginAccessIdentity.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["arn"] = state?.arn;
resourceInputs["callerReference"] = state?.callerReference;
resourceInputs["cloudfrontAccessIdentityPath"] = state?.cloudfrontAccessIdentityPath;
resourceInputs["comment"] = state?.comment;
resourceInputs["etag"] = state?.etag;
resourceInputs["iamArn"] = state?.iamArn;
resourceInputs["s3CanonicalUserId"] = state?.s3CanonicalUserId;
}
else {
const args = argsOrState;
resourceInputs["comment"] = args?.comment;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["callerReference"] = undefined /*out*/;
resourceInputs["cloudfrontAccessIdentityPath"] = undefined /*out*/;
resourceInputs["etag"] = undefined /*out*/;
resourceInputs["iamArn"] = undefined /*out*/;
resourceInputs["s3CanonicalUserId"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(OriginAccessIdentity.__pulumiType, name, resourceInputs, opts);
}
}
exports.OriginAccessIdentity = OriginAccessIdentity;
/** @internal */
OriginAccessIdentity.__pulumiType = 'aws:cloudfront/originAccessIdentity:OriginAccessIdentity';
//# sourceMappingURL=originAccessIdentity.js.map
;