UNPKG

@pulumiverse/scaleway

Version:

A Pulumi package for creating and managing Scaleway cloud resources.

209 lines 8.19 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Policy = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * Creates and manages Scaleway IAM Policies. For more information refer to the [IAM API documentation](https://www.scaleway.com/en/developers/api/iam/#path-policies-create-a-new-policy). * * > You can find a detailed list of all permission sets available at Scaleway in the permission sets [reference page](https://www.scaleway.com/en/docs/iam/reference-content/permission-sets/). * * ## Example Usage * * ### Create a policy for an organization's project * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@pulumiverse/scaleway"; * * const _default = scaleway.account.getProject({ * name: "default", * }); * const app = new scaleway.iam.Application("app", {name: "my app"}); * const objectReadOnly = new scaleway.iam.Policy("object_read_only", { * name: "my policy", * description: "gives app readonly access to object storage in project", * applicationId: app.id, * rules: [{ * projectIds: [_default.then(_default => _default.id)], * permissionSetNames: ["ObjectStorageReadOnly"], * }], * }); * ``` * * ### Create a policy for all current and future projects in an organization * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@pulumiverse/scaleway"; * * const app = new scaleway.iam.Application("app", {name: "my app"}); * const objectReadOnly = new scaleway.iam.Policy("object_read_only", { * name: "my policy", * description: "gives app readonly access to object storage in project", * applicationId: app.id, * rules: [{ * organizationId: app.organizationId, * permissionSetNames: ["ObjectStorageReadOnly"], * }], * }); * ``` * * ### Create a permission for multiple users using a group * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@pulumiverse/scaleway"; * import * as std from "@pulumi/std"; * * const users = [ * "user1@mail.com", * "user2@mail.com", * ]; * const projectName = "default"; * const project = scaleway.account.getProject({ * name: projectName, * }); * const usersGetUser = .reduce((__obj, [__key, __value]) => ({ ...__obj, [String(__key)]: scaleway.iam.getUser({ * email: __value, * }) }), {}); * const withUsers = new scaleway.iam.Group("with_users", { * name: "developers", * userIds: Object.values(usersGetUser).map(user => (user.id)), * }); * const iamTfStoragePolicy = new scaleway.iam.Policy("iam_tf_storage_policy", { * name: "developers permissions", * groupId: withUsers.id, * rules: [{ * projectIds: [project.then(project => project.id)], * permissionSetNames: ["InstancesReadOnly"], * }], * }); * ``` * * ### Create a policy with a particular condition * * IAM policy rule can use a condition to be applied. * The following variables are available: * * - `request.ip` * - `request.user_agent` * - `request.time` * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@pulumiverse/scaleway"; * * const main = new scaleway.iam.Policy("main", { * name: "tf_tests_policy_condition", * noPrincipal: true, * rules: [{ * organizationId: "%s", * permissionSetNames: ["AllProductsFullAccess"], * condition: "request.user_agent == 'My User Agent'", * }], * }); * ``` * * ## Import * * Policies can be imported using the `{id}`, e.g. * * ```sh * $ pulumi import scaleway:iam/policy:Policy main 11111111-1111-1111-1111-111111111111 * ``` */ class Policy extends pulumi.CustomResource { /** * Get an existing Policy 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 Policy(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'scaleway:iam/policy:Policy'; /** * Returns true if the given object is an instance of Policy. 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'] === Policy.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["applicationId"] = state?.applicationId; resourceInputs["createdAt"] = state?.createdAt; resourceInputs["description"] = state?.description; resourceInputs["editable"] = state?.editable; resourceInputs["groupId"] = state?.groupId; resourceInputs["name"] = state?.name; resourceInputs["noPrincipal"] = state?.noPrincipal; resourceInputs["organizationId"] = state?.organizationId; resourceInputs["rules"] = state?.rules; resourceInputs["tags"] = state?.tags; resourceInputs["updatedAt"] = state?.updatedAt; resourceInputs["userId"] = state?.userId; } else { const args = argsOrState; if (args?.rules === undefined && !opts.urn) { throw new Error("Missing required property 'rules'"); } resourceInputs["applicationId"] = args?.applicationId; resourceInputs["description"] = args?.description; resourceInputs["groupId"] = args?.groupId; resourceInputs["name"] = args?.name; resourceInputs["noPrincipal"] = args?.noPrincipal; resourceInputs["organizationId"] = args?.organizationId; resourceInputs["rules"] = args?.rules; resourceInputs["tags"] = args?.tags; resourceInputs["userId"] = args?.userId; resourceInputs["createdAt"] = undefined /*out*/; resourceInputs["editable"] = undefined /*out*/; resourceInputs["updatedAt"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const aliasOpts = { aliases: [{ type: "scaleway:index/iamPolicy:IamPolicy" }] }; opts = pulumi.mergeOptions(opts, aliasOpts); super(Policy.__pulumiType, name, resourceInputs, opts); } } exports.Policy = Policy; //# sourceMappingURL=policy.js.map