UNPKG

@huaweicloudos/pulumi

Version:

A Pulumi package for creating and managing Huaweicloud cloud resources.

343 lines 12.9 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Domain = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Manages a CDN domain resource within HuaweiCloud. * * ## Example Usage * ### Create a CDN domain * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const domainName = config.requireObject("domainName"); * const originServer = config.requireObject("originServer"); * const test = new huaweicloud.cdn.Domain("test", { * type: "web", * serviceArea: "mainland_china", * sources: [{ * origin: originServer, * originType: "ipaddr", * active: 1, * }], * tags: { * key: "val", * foo: "bar", * }, * }); * ``` * ### Create a CDN domain with cache rules * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const domainName = config.requireObject("domainName"); * const originServer = config.requireObject("originServer"); * const test = new huaweicloud.cdn.Domain("test", { * type: "web", * serviceArea: "mainland_china", * sources: [{ * origin: originServer, * originType: "ipaddr", * active: 1, * }], * cacheSettings: { * rules: [{ * ruleType: "all", * ttl: 180, * ttlType: "d", * priority: 2, * urlParameterType: "ignore_url_params", * }], * }, * }); * ``` * ### Create a CDN domain with configs * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as fs from "fs"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const domainName = config.requireObject("domainName"); * const originServer = config.requireObject("originServer"); * const ipOrDomain = config.requireObject("ipOrDomain"); * const caCertificateBody = config.requireObject("caCertificateBody"); * const test = new huaweicloud.cdn.Domain("test", { * type: "web", * serviceArea: "mainland_china", * sources: [{ * origin: originServer, * originType: "ipaddr", * active: 1, * }], * configs: { * originProtocol: "http", * ipv6Enable: true, * rangeBasedRetrievalEnabled: true, * description: "test description", * httpsSettings: { * certificateName: "terraform-test", * certificateBody: fs.readFileSync("your_directory/chain.cer"), * http2Enabled: true, * httpsEnabled: true, * privateKey: fs.readFileSync("your_directory/server_private.key"), * ocspStaplingStatus: "on", * }, * retrievalRequestHeaders: [{ * name: "test-name", * value: "test-val", * action: "set", * }], * httpResponseHeaders: [{ * name: "test-name", * value: "test-val", * action: "set", * }], * urlSigning: { * enabled: true, * type: "type_a", * signMethod: "md5", * matchType: "all", * signArg: "Psd_123", * key: "A27jtfSTy13q7A0UnTA9vpxYXEb", * backupKey: "S36klgTFa60q3V8DmSK2hwfBOYp", * timeFormat: "dec", * expireTime: 30, * inheritConfig: { * enabled: true, * inheritType: "m3u8", * inheritTimeType: "sys_time", * }, * }, * flexibleOrigins: [{ * matchType: "all", * priority: 1, * backSources: { * httpPort: 80, * httpsPort: 443, * ipOrDomain: ipOrDomain, * sourcesType: "ipaddr", * }, * }], * requestLimitRules: [{ * limitRateAfter: 50, * limitRateValue: 1048576, * matchType: "catalog", * matchValue: "/test/ff", * priority: 4, * type: "size", * }], * errorCodeCaches: [{ * code: 403, * ttl: 70, * }], * originRequestUrlRewrites: [{ * matchType: "file_path", * priority: 10, * sourceUrl: "/tt/abc.txt", * targetUrl: `/new/$1/$2.html`, * }], * userAgentFilter: { * type: "black", * includeEmpty: "false", * uaLists: ["t1*"], * }, * sni: { * enabled: true, * serverName: "backup.all.cn.com", * }, * requestUrlRewrites: [{ * executionMode: "break", * redirectUrl: "/test/index.html", * condition: { * matchType: "catalog", * matchValue: "/test/folder/1", * priority: 10, * }, * }], * browserCacheRules: [{ * cacheType: "ttl", * ttl: 30, * ttlUnit: "m", * condition: { * matchType: "file_extension", * matchValue: ".jpg,.zip,.gz", * priority: 2, * }, * }], * clientCert: { * enabled: true, * hosts: "demo1.com.cn|demo2.com.cn|demo3.com.cn", * trustedCert: caCertificateBody, * }, * remoteAuth: { * enabled: true, * remoteAuthRules: { * authFailedStatus: "503", * authServer: "https://testdomain-update.com", * authSuccessStatus: "302", * fileTypeSetting: "all", * requestMethod: "POST", * reserveArgsSetting: "reserve_all_args", * reserveHeadersSetting: "reserve_all_headers", * responseStatus: "206", * timeout: 3000, * timeoutAction: "forbid", * addCustomArgsRules: [{ * key: "http_user_agent", * type: "nginx_preset_var", * value: `$server_protocol`, * }], * }, * }, * compress: { * enabled: false, * }, * forceRedirect: { * enabled: true, * type: "http", * }, * referer: { * type: "white", * value: "*.common.com,192.187.2.43,www.test.top:4990", * includeEmpty: false, * }, * }, * }); * ``` * ### Create a CDN domain with SCM certificate HTTPS configs * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const domainName = config.requireObject("domainName"); * const originServer = config.requireObject("originServer"); * const certificateName = config.requireObject("certificateName"); * const scmCertificateId = config.requireObject("scmCertificateId"); * const test = new huaweicloud.cdn.Domain("test", { * type: "web", * serviceArea: "mainland_china", * sources: [{ * origin: originServer, * originType: "ipaddr", * active: 1, * }], * configs: { * httpsSettings: { * certificateSource: 2, * certificateName: certificateName, * scmCertificateId: scmCertificateId, * certificateType: "server", * http2Enabled: true, * httpsEnabled: true, * }, * }, * }); * ``` * * ## Import * * The CDN domain resource can be imported using the domain `name`, e.g. bash * * ```sh * $ pulumi import huaweicloud:Cdn/domain:Domain test <name> * ``` * * Note that the imported state may not be identical to your resource definition, due to some attributes missing from the API response, security or some other reason. The missing attributes include`enterprise_project_id`, `configs.0.url_signing.0.key`, `configs.0.url_signing.0.backup_key`, `configs.0.https_settings.0.certificate_body`, `configs.0.https_settings.0.private_key`, `cache_settings`. It is generally recommended running `terraform plan` after importing a resource. You can then decide if changes should be applied to the resource, or the resource definition should be updated to align with the resource. Also, you can ignore changes as below. hcl resource "huaweicloud_cdn_domain" "test" { * * ... * * lifecycle { * * ignore_changes = [ * * enterprise_project_id, configs.0.url_signing.0.key, configs.0.url_signing.0.backup_key, * * configs.0.https_settings.0.certificate_body, configs.0.https_settings.0.private_key, cache_settings, * * ] * * } } */ class Domain extends pulumi.CustomResource { /** * Get an existing Domain 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 Domain(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Domain. 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'] === Domain.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["cacheSettings"] = state ? state.cacheSettings : undefined; resourceInputs["cname"] = state ? state.cname : undefined; resourceInputs["configs"] = state ? state.configs : undefined; resourceInputs["domainName"] = state ? state.domainName : undefined; resourceInputs["domainStatus"] = state ? state.domainStatus : undefined; resourceInputs["enableForceNew"] = state ? state.enableForceNew : undefined; resourceInputs["enterpriseProjectId"] = state ? state.enterpriseProjectId : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["serviceArea"] = state ? state.serviceArea : undefined; resourceInputs["sources"] = state ? state.sources : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["type"] = state ? state.type : undefined; } else { const args = argsOrState; if ((!args || args.sources === undefined) && !opts.urn) { throw new Error("Missing required property 'sources'"); } if ((!args || args.type === undefined) && !opts.urn) { throw new Error("Missing required property 'type'"); } resourceInputs["cacheSettings"] = args ? args.cacheSettings : undefined; resourceInputs["configs"] = args ? args.configs : undefined; resourceInputs["enableForceNew"] = args ? args.enableForceNew : undefined; resourceInputs["enterpriseProjectId"] = args ? args.enterpriseProjectId : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["serviceArea"] = args ? args.serviceArea : undefined; resourceInputs["sources"] = args ? args.sources : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["type"] = args ? args.type : undefined; resourceInputs["cname"] = undefined /*out*/; resourceInputs["domainName"] = undefined /*out*/; resourceInputs["domainStatus"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Domain.__pulumiType, name, resourceInputs, opts); } } exports.Domain = Domain; /** @internal */ Domain.__pulumiType = 'huaweicloud:Cdn/domain:Domain'; //# sourceMappingURL=domain.js.map