@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
92 lines • 4.24 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.RegistryPolicy = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides an Elastic Container Registry Policy.
*
* > **NOTE on ECR Registry Policies:** While the AWS Management Console interface may suggest the ability to define multiple policies by creating multiple statements, ECR registry policies are effectively managed as singular entities at the regional level by the AWS APIs. Therefore, the `aws.ecr.RegistryPolicy` resource should be configured only once per region with all necessary statements defined in the same policy. Attempting to define multiple `aws.ecr.RegistryPolicy` resources may result in perpetual differences, with one policy overriding another.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const current = aws.getCallerIdentity({});
* const currentGetRegion = aws.getRegion({});
* const currentGetPartition = aws.getPartition({});
* const example = new aws.ecr.RegistryPolicy("example", {policy: JSON.stringify({
* Version: "2012-10-17",
* Statement: [{
* Sid: "testpolicy",
* Effect: "Allow",
* Principal: {
* AWS: Promise.all([currentGetPartition, current]).then(([currentGetPartition, current]) => `arn:${currentGetPartition.partition}:iam::${current.accountId}:root`),
* },
* Action: ["ecr:ReplicateImage"],
* Resource: [Promise.all([currentGetPartition, currentGetRegion, current]).then(([currentGetPartition, currentGetRegion, current]) => `arn:${currentGetPartition.partition}:ecr:${currentGetRegion.region}:${current.accountId}:repository/*`)],
* }],
* })});
* ```
*
* ## Import
*
* Using `pulumi import`, import ECR Registry Policy using the registry id. For example:
*
* ```sh
* $ pulumi import aws:ecr/registryPolicy:RegistryPolicy example 123456789012
* ```
*/
class RegistryPolicy extends pulumi.CustomResource {
/**
* Get an existing RegistryPolicy 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 RegistryPolicy(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of RegistryPolicy. 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'] === RegistryPolicy.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["policy"] = state?.policy;
resourceInputs["region"] = state?.region;
resourceInputs["registryId"] = state?.registryId;
}
else {
const args = argsOrState;
if (args?.policy === undefined && !opts.urn) {
throw new Error("Missing required property 'policy'");
}
resourceInputs["policy"] = args?.policy;
resourceInputs["region"] = args?.region;
resourceInputs["registryId"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(RegistryPolicy.__pulumiType, name, resourceInputs, opts);
}
}
exports.RegistryPolicy = RegistryPolicy;
/** @internal */
RegistryPolicy.__pulumiType = 'aws:ecr/registryPolicy:RegistryPolicy';
//# sourceMappingURL=registryPolicy.js.map