@huaweicloudos/pulumi
Version:
A Pulumi package for creating and managing Huaweicloud cloud resources.
480 lines (479 loc) • 18.2 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import { input as inputs, output as outputs } from "../types";
/**
* 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,
*
* ]
*
* } }
*/
export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: DomainState, opts?: pulumi.CustomResourceOptions): Domain;
/**
* 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: any): obj is Domain;
/**
* Specifies the cache configuration. The cacheSettings structure
* is documented below.
*/
readonly cacheSettings: pulumi.Output<outputs.Cdn.DomainCacheSettings>;
/**
* The CNAME of the acceleration domain name.
*/
readonly cname: pulumi.Output<string>;
/**
* Specifies the domain configuration items. The configs structure is
* documented below.
*/
readonly configs: pulumi.Output<outputs.Cdn.DomainConfigs>;
/**
* schema: Internal
*/
readonly domainName: pulumi.Output<string>;
/**
* The status of the acceleration domain name. The available values are
* **online**, **offline**, **configuring**, **configure_failed**, **checking**, **check_failed** and **deleting**.
*/
readonly domainStatus: pulumi.Output<string>;
readonly enableForceNew: pulumi.Output<string | undefined>;
/**
* Specifies the enterprise project ID.
*/
readonly enterpriseProjectId: pulumi.Output<string | undefined>;
/**
* Specifies the HTTP response header. Valid values are **Content-Disposition**, **Content-Language**,
* **Access-Control-Allow-Origin**, **Access-Control-Allow-Methods**, **Access-Control-Max-Age**, **Access-Control-Expose-Headers**,
* **Access-Control-Allow-Headers** or custom headers. A header contains `1` to `100` characters, including letters, digits,
* and hyphens (-), and starts with a letter.
*/
readonly name: pulumi.Output<string>;
/**
* Specifies the area covered by the acceleration service.
* Valid values are as follows:
* + **mainland_china**: Indicates that the service scope is mainland China.
* + **outside_mainland_china**: Indicates that the service scope is outside mainland China.
* + **global**: Indicates that the service scope is global.
*/
readonly serviceArea: pulumi.Output<string>;
/**
* Specifies an array of one or more objects specifying origin server settings.
* A maximum of `50` origin site configurations can be configured.
* The sources structure is documented below.
*/
readonly sources: pulumi.Output<outputs.Cdn.DomainSource[]>;
/**
* Specifies the key/value pairs to associate with the domain.
*/
readonly tags: pulumi.Output<{
[key: string]: string;
} | undefined>;
/**
* Specifies the blacklist and whitelist rule type. Valid values are:
* + **black**: Blacklist. Users in regions specified in the blacklist cannot access resources and status code `403` is
* returned.
* + **white**: Whitelist. Only users in regions specified in the whitelist can access resources. Status code `403` is
* returned for other users.
*/
readonly type: pulumi.Output<string>;
/**
* Create a Domain resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: DomainArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering Domain resources.
*/
export interface DomainState {
/**
* Specifies the cache configuration. The cacheSettings structure
* is documented below.
*/
cacheSettings?: pulumi.Input<inputs.Cdn.DomainCacheSettings>;
/**
* The CNAME of the acceleration domain name.
*/
cname?: pulumi.Input<string>;
/**
* Specifies the domain configuration items. The configs structure is
* documented below.
*/
configs?: pulumi.Input<inputs.Cdn.DomainConfigs>;
/**
* schema: Internal
*/
domainName?: pulumi.Input<string>;
/**
* The status of the acceleration domain name. The available values are
* **online**, **offline**, **configuring**, **configure_failed**, **checking**, **check_failed** and **deleting**.
*/
domainStatus?: pulumi.Input<string>;
enableForceNew?: pulumi.Input<string>;
/**
* Specifies the enterprise project ID.
*/
enterpriseProjectId?: pulumi.Input<string>;
/**
* Specifies the HTTP response header. Valid values are **Content-Disposition**, **Content-Language**,
* **Access-Control-Allow-Origin**, **Access-Control-Allow-Methods**, **Access-Control-Max-Age**, **Access-Control-Expose-Headers**,
* **Access-Control-Allow-Headers** or custom headers. A header contains `1` to `100` characters, including letters, digits,
* and hyphens (-), and starts with a letter.
*/
name?: pulumi.Input<string>;
/**
* Specifies the area covered by the acceleration service.
* Valid values are as follows:
* + **mainland_china**: Indicates that the service scope is mainland China.
* + **outside_mainland_china**: Indicates that the service scope is outside mainland China.
* + **global**: Indicates that the service scope is global.
*/
serviceArea?: pulumi.Input<string>;
/**
* Specifies an array of one or more objects specifying origin server settings.
* A maximum of `50` origin site configurations can be configured.
* The sources structure is documented below.
*/
sources?: pulumi.Input<pulumi.Input<inputs.Cdn.DomainSource>[]>;
/**
* Specifies the key/value pairs to associate with the domain.
*/
tags?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
}>;
/**
* Specifies the blacklist and whitelist rule type. Valid values are:
* + **black**: Blacklist. Users in regions specified in the blacklist cannot access resources and status code `403` is
* returned.
* + **white**: Whitelist. Only users in regions specified in the whitelist can access resources. Status code `403` is
* returned for other users.
*/
type?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a Domain resource.
*/
export interface DomainArgs {
/**
* Specifies the cache configuration. The cacheSettings structure
* is documented below.
*/
cacheSettings?: pulumi.Input<inputs.Cdn.DomainCacheSettings>;
/**
* Specifies the domain configuration items. The configs structure is
* documented below.
*/
configs?: pulumi.Input<inputs.Cdn.DomainConfigs>;
enableForceNew?: pulumi.Input<string>;
/**
* Specifies the enterprise project ID.
*/
enterpriseProjectId?: pulumi.Input<string>;
/**
* Specifies the HTTP response header. Valid values are **Content-Disposition**, **Content-Language**,
* **Access-Control-Allow-Origin**, **Access-Control-Allow-Methods**, **Access-Control-Max-Age**, **Access-Control-Expose-Headers**,
* **Access-Control-Allow-Headers** or custom headers. A header contains `1` to `100` characters, including letters, digits,
* and hyphens (-), and starts with a letter.
*/
name?: pulumi.Input<string>;
/**
* Specifies the area covered by the acceleration service.
* Valid values are as follows:
* + **mainland_china**: Indicates that the service scope is mainland China.
* + **outside_mainland_china**: Indicates that the service scope is outside mainland China.
* + **global**: Indicates that the service scope is global.
*/
serviceArea?: pulumi.Input<string>;
/**
* Specifies an array of one or more objects specifying origin server settings.
* A maximum of `50` origin site configurations can be configured.
* The sources structure is documented below.
*/
sources: pulumi.Input<pulumi.Input<inputs.Cdn.DomainSource>[]>;
/**
* Specifies the key/value pairs to associate with the domain.
*/
tags?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
}>;
/**
* Specifies the blacklist and whitelist rule type. Valid values are:
* + **black**: Blacklist. Users in regions specified in the blacklist cannot access resources and status code `403` is
* returned.
* + **white**: Whitelist. Only users in regions specified in the whitelist can access resources. Status code `403` is
* returned for other users.
*/
type: pulumi.Input<string>;
}