alicloud.cfg.Remediation
Explore with Pulumi AI
Provides a Config Remediation resource.
For information about Config Remediation and how to use it, see What is Remediation.
NOTE: Available since v1.204.0.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
import * as random from "@pulumi/random";
const config = new pulumi.Config();
const name = config.get("name") || "tf-example-oss";
const default = alicloud.getRegions({
current: true,
});
const defaultInteger = new random.index.Integer("default", {
min: 10000,
max: 99999,
});
const defaultBucket = new alicloud.oss.Bucket("default", {
bucket: `${name}-${defaultInteger.result}`,
acl: "public-read",
tags: {
For: "example",
},
});
const defaultRule = new alicloud.cfg.Rule("default", {
description: "If the ACL policy of the OSS bucket denies read access from the Internet, the configuration is considered compliant.",
sourceOwner: "ALIYUN",
sourceIdentifier: "oss-bucket-public-read-prohibited",
riskLevel: 1,
tagKeyScope: "For",
tagValueScope: "example",
regionIdsScope: _default.then(_default => _default.regions?.[0]?.id),
configRuleTriggerTypes: "ConfigurationItemChangeNotification",
resourceTypesScopes: ["ACS::OSS::Bucket"],
ruleName: "oss-bucket-public-read-prohibited",
});
const defaultRemediation = new alicloud.cfg.Remediation("default", {
configRuleId: defaultRule.configRuleId,
remediationTemplateId: "ACS-OSS-PutBucketAcl",
remediationSourceType: "ALIYUN",
invokeType: "MANUAL_EXECUTION",
params: pulumi.all([defaultBucket.bucket, _default]).apply(([bucket, _default]) => `{"bucketName": "${bucket}", "regionId": "${_default.regions?.[0]?.id}", "permissionName": "private"}`),
remediationType: "OOS",
});
import pulumi
import pulumi_alicloud as alicloud
import pulumi_random as random
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "tf-example-oss"
default = alicloud.get_regions(current=True)
default_integer = random.index.Integer("default",
min=10000,
max=99999)
default_bucket = alicloud.oss.Bucket("default",
bucket=f"{name}-{default_integer['result']}",
acl="public-read",
tags={
"For": "example",
})
default_rule = alicloud.cfg.Rule("default",
description="If the ACL policy of the OSS bucket denies read access from the Internet, the configuration is considered compliant.",
source_owner="ALIYUN",
source_identifier="oss-bucket-public-read-prohibited",
risk_level=1,
tag_key_scope="For",
tag_value_scope="example",
region_ids_scope=default.regions[0].id,
config_rule_trigger_types="ConfigurationItemChangeNotification",
resource_types_scopes=["ACS::OSS::Bucket"],
rule_name="oss-bucket-public-read-prohibited")
default_remediation = alicloud.cfg.Remediation("default",
config_rule_id=default_rule.config_rule_id,
remediation_template_id="ACS-OSS-PutBucketAcl",
remediation_source_type="ALIYUN",
invoke_type="MANUAL_EXECUTION",
params=default_bucket.bucket.apply(lambda bucket: f"{{\"bucketName\": \"{bucket}\", \"regionId\": \"{default.regions[0].id}\", \"permissionName\": \"private\"}}"),
remediation_type="OOS")
package main
import (
"fmt"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/cfg"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/oss"
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
name := "tf-example-oss"
if param := cfg.Get("name"); param != "" {
name = param
}
_default, err := alicloud.GetRegions(ctx, &alicloud.GetRegionsArgs{
Current: pulumi.BoolRef(true),
}, nil)
if err != nil {
return err
}
defaultInteger, err := random.NewInteger(ctx, "default", &random.IntegerArgs{
Min: 10000,
Max: 99999,
})
if err != nil {
return err
}
defaultBucket, err := oss.NewBucket(ctx, "default", &oss.BucketArgs{
Bucket: pulumi.String(fmt.Sprintf("%v-%v", name, defaultInteger.Result)),
Acl: pulumi.String("public-read"),
Tags: pulumi.Map{
"For": pulumi.Any("example"),
},
})
if err != nil {
return err
}
defaultRule, err := cfg.NewRule(ctx, "default", &cfg.RuleArgs{
Description: pulumi.String("If the ACL policy of the OSS bucket denies read access from the Internet, the configuration is considered compliant."),
SourceOwner: pulumi.String("ALIYUN"),
SourceIdentifier: pulumi.String("oss-bucket-public-read-prohibited"),
RiskLevel: pulumi.Int(1),
TagKeyScope: pulumi.String("For"),
TagValueScope: pulumi.String("example"),
RegionIdsScope: pulumi.String(_default.Regions[0].Id),
ConfigRuleTriggerTypes: pulumi.String("ConfigurationItemChangeNotification"),
ResourceTypesScopes: pulumi.StringArray{
pulumi.String("ACS::OSS::Bucket"),
},
RuleName: pulumi.String("oss-bucket-public-read-prohibited"),
})
if err != nil {
return err
}
_, err = cfg.NewRemediation(ctx, "default", &cfg.RemediationArgs{
ConfigRuleId: defaultRule.ConfigRuleId,
RemediationTemplateId: pulumi.String("ACS-OSS-PutBucketAcl"),
RemediationSourceType: pulumi.String("ALIYUN"),
InvokeType: pulumi.String("MANUAL_EXECUTION"),
Params: defaultBucket.Bucket.ApplyT(func(bucket *string) (string, error) {
return fmt.Sprintf("{\"bucketName\": \"%v\", \"regionId\": \"%v\", \"permissionName\": \"private\"}", bucket, _default.Regions[0].Id), nil
}).(pulumi.StringOutput),
RemediationType: pulumi.String("OOS"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
using Random = Pulumi.Random;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "tf-example-oss";
var @default = AliCloud.GetRegions.Invoke(new()
{
Current = true,
});
var defaultInteger = new Random.Index.Integer("default", new()
{
Min = 10000,
Max = 99999,
});
var defaultBucket = new AliCloud.Oss.Bucket("default", new()
{
BucketName = $"{name}-{defaultInteger.Result}",
Acl = "public-read",
Tags =
{
{ "For", "example" },
},
});
var defaultRule = new AliCloud.Cfg.Rule("default", new()
{
Description = "If the ACL policy of the OSS bucket denies read access from the Internet, the configuration is considered compliant.",
SourceOwner = "ALIYUN",
SourceIdentifier = "oss-bucket-public-read-prohibited",
RiskLevel = 1,
TagKeyScope = "For",
TagValueScope = "example",
RegionIdsScope = @default.Apply(@default => @default.Apply(getRegionsResult => getRegionsResult.Regions[0]?.Id)),
ConfigRuleTriggerTypes = "ConfigurationItemChangeNotification",
ResourceTypesScopes = new[]
{
"ACS::OSS::Bucket",
},
RuleName = "oss-bucket-public-read-prohibited",
});
var defaultRemediation = new AliCloud.Cfg.Remediation("default", new()
{
ConfigRuleId = defaultRule.ConfigRuleId,
RemediationTemplateId = "ACS-OSS-PutBucketAcl",
RemediationSourceType = "ALIYUN",
InvokeType = "MANUAL_EXECUTION",
Params = Output.Tuple(defaultBucket.BucketName, @default).Apply(values =>
{
var bucket = values.Item1;
var @default = values.Item2;
return $"{{\"bucketName\": \"{bucket}\", \"regionId\": \"{@default.Apply(getRegionsResult => getRegionsResult.Regions[0]?.Id)}\", \"permissionName\": \"private\"}}";
}),
RemediationType = "OOS",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.inputs.GetRegionsArgs;
import com.pulumi.random.integer;
import com.pulumi.random.IntegerArgs;
import com.pulumi.alicloud.oss.Bucket;
import com.pulumi.alicloud.oss.BucketArgs;
import com.pulumi.alicloud.cfg.Rule;
import com.pulumi.alicloud.cfg.RuleArgs;
import com.pulumi.alicloud.cfg.Remediation;
import com.pulumi.alicloud.cfg.RemediationArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var config = ctx.config();
final var name = config.get("name").orElse("tf-example-oss");
final var default = AlicloudFunctions.getRegions(GetRegionsArgs.builder()
.current(true)
.build());
var defaultInteger = new Integer("defaultInteger", IntegerArgs.builder()
.min(10000)
.max(99999)
.build());
var defaultBucket = new Bucket("defaultBucket", BucketArgs.builder()
.bucket(String.format("%s-%s", name,defaultInteger.result()))
.acl("public-read")
.tags(Map.of("For", "example"))
.build());
var defaultRule = new Rule("defaultRule", RuleArgs.builder()
.description("If the ACL policy of the OSS bucket denies read access from the Internet, the configuration is considered compliant.")
.sourceOwner("ALIYUN")
.sourceIdentifier("oss-bucket-public-read-prohibited")
.riskLevel(1)
.tagKeyScope("For")
.tagValueScope("example")
.regionIdsScope(default_.regions()[0].id())
.configRuleTriggerTypes("ConfigurationItemChangeNotification")
.resourceTypesScopes("ACS::OSS::Bucket")
.ruleName("oss-bucket-public-read-prohibited")
.build());
var defaultRemediation = new Remediation("defaultRemediation", RemediationArgs.builder()
.configRuleId(defaultRule.configRuleId())
.remediationTemplateId("ACS-OSS-PutBucketAcl")
.remediationSourceType("ALIYUN")
.invokeType("MANUAL_EXECUTION")
.params(defaultBucket.bucket().applyValue(bucket -> String.format("{{\"bucketName\": \"%s\", \"regionId\": \"%s\", \"permissionName\": \"private\"}}", bucket,default_.regions()[0].id())))
.remediationType("OOS")
.build());
}
}
configuration:
name:
type: string
default: tf-example-oss
resources:
defaultInteger:
type: random:integer
name: default
properties:
min: 10000
max: 99999
defaultBucket:
type: alicloud:oss:Bucket
name: default
properties:
bucket: ${name}-${defaultInteger.result}
acl: public-read
tags:
For: example
defaultRule:
type: alicloud:cfg:Rule
name: default
properties:
description: If the ACL policy of the OSS bucket denies read access from the Internet, the configuration is considered compliant.
sourceOwner: ALIYUN
sourceIdentifier: oss-bucket-public-read-prohibited
riskLevel: 1
tagKeyScope: For
tagValueScope: example
regionIdsScope: ${default.regions[0].id}
configRuleTriggerTypes: ConfigurationItemChangeNotification
resourceTypesScopes:
- ACS::OSS::Bucket
ruleName: oss-bucket-public-read-prohibited
defaultRemediation:
type: alicloud:cfg:Remediation
name: default
properties:
configRuleId: ${defaultRule.configRuleId}
remediationTemplateId: ACS-OSS-PutBucketAcl
remediationSourceType: ALIYUN
invokeType: MANUAL_EXECUTION
params: '{"bucketName": "${defaultBucket.bucket}", "regionId": "${default.regions[0].id}", "permissionName": "private"}'
remediationType: OOS
variables:
default:
fn::invoke:
Function: alicloud:getRegions
Arguments:
current: true
Create Remediation Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Remediation(name: string, args: RemediationArgs, opts?: CustomResourceOptions);
@overload
def Remediation(resource_name: str,
args: RemediationArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Remediation(resource_name: str,
opts: Optional[ResourceOptions] = None,
config_rule_id: Optional[str] = None,
invoke_type: Optional[str] = None,
params: Optional[str] = None,
remediation_template_id: Optional[str] = None,
remediation_type: Optional[str] = None,
remediation_source_type: Optional[str] = None)
func NewRemediation(ctx *Context, name string, args RemediationArgs, opts ...ResourceOption) (*Remediation, error)
public Remediation(string name, RemediationArgs args, CustomResourceOptions? opts = null)
public Remediation(String name, RemediationArgs args)
public Remediation(String name, RemediationArgs args, CustomResourceOptions options)
type: alicloud:cfg:Remediation
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args RemediationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args RemediationArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args RemediationArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RemediationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args RemediationArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var remediationResource = new AliCloud.Cfg.Remediation("remediationResource", new()
{
ConfigRuleId = "string",
InvokeType = "string",
Params = "string",
RemediationTemplateId = "string",
RemediationType = "string",
RemediationSourceType = "string",
});
example, err := cfg.NewRemediation(ctx, "remediationResource", &cfg.RemediationArgs{
ConfigRuleId: pulumi.String("string"),
InvokeType: pulumi.String("string"),
Params: pulumi.String("string"),
RemediationTemplateId: pulumi.String("string"),
RemediationType: pulumi.String("string"),
RemediationSourceType: pulumi.String("string"),
})
var remediationResource = new Remediation("remediationResource", RemediationArgs.builder()
.configRuleId("string")
.invokeType("string")
.params("string")
.remediationTemplateId("string")
.remediationType("string")
.remediationSourceType("string")
.build());
remediation_resource = alicloud.cfg.Remediation("remediationResource",
config_rule_id="string",
invoke_type="string",
params="string",
remediation_template_id="string",
remediation_type="string",
remediation_source_type="string")
const remediationResource = new alicloud.cfg.Remediation("remediationResource", {
configRuleId: "string",
invokeType: "string",
params: "string",
remediationTemplateId: "string",
remediationType: "string",
remediationSourceType: "string",
});
type: alicloud:cfg:Remediation
properties:
configRuleId: string
invokeType: string
params: string
remediationSourceType: string
remediationTemplateId: string
remediationType: string
Remediation Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The Remediation resource accepts the following input properties:
- Config
Rule stringId - Rule ID.
- Invoke
Type string - Execution type, valid values:
Manual
,Automatic
. - Params string
- Remediation parameter.
- Remediation
Template stringId - Remediation template ID.
- Remediation
Type string Remediation type, valid values:
OOS
,FC
.The following arguments will be discarded. Please use new fields as soon as possible:
- Remediation
Source stringType - Remediation resource type, valid values:
ALIYUN
,CUSTOMER
.
- Config
Rule stringId - Rule ID.
- Invoke
Type string - Execution type, valid values:
Manual
,Automatic
. - Params string
- Remediation parameter.
- Remediation
Template stringId - Remediation template ID.
- Remediation
Type string Remediation type, valid values:
OOS
,FC
.The following arguments will be discarded. Please use new fields as soon as possible:
- Remediation
Source stringType - Remediation resource type, valid values:
ALIYUN
,CUSTOMER
.
- config
Rule StringId - Rule ID.
- invoke
Type String - Execution type, valid values:
Manual
,Automatic
. - params String
- Remediation parameter.
- remediation
Template StringId - Remediation template ID.
- remediation
Type String Remediation type, valid values:
OOS
,FC
.The following arguments will be discarded. Please use new fields as soon as possible:
- remediation
Source StringType - Remediation resource type, valid values:
ALIYUN
,CUSTOMER
.
- config
Rule stringId - Rule ID.
- invoke
Type string - Execution type, valid values:
Manual
,Automatic
. - params string
- Remediation parameter.
- remediation
Template stringId - Remediation template ID.
- remediation
Type string Remediation type, valid values:
OOS
,FC
.The following arguments will be discarded. Please use new fields as soon as possible:
- remediation
Source stringType - Remediation resource type, valid values:
ALIYUN
,CUSTOMER
.
- config_
rule_ strid - Rule ID.
- invoke_
type str - Execution type, valid values:
Manual
,Automatic
. - params str
- Remediation parameter.
- remediation_
template_ strid - Remediation template ID.
- remediation_
type str Remediation type, valid values:
OOS
,FC
.The following arguments will be discarded. Please use new fields as soon as possible:
- remediation_
source_ strtype - Remediation resource type, valid values:
ALIYUN
,CUSTOMER
.
- config
Rule StringId - Rule ID.
- invoke
Type String - Execution type, valid values:
Manual
,Automatic
. - params String
- Remediation parameter.
- remediation
Template StringId - Remediation template ID.
- remediation
Type String Remediation type, valid values:
OOS
,FC
.The following arguments will be discarded. Please use new fields as soon as possible:
- remediation
Source StringType - Remediation resource type, valid values:
ALIYUN
,CUSTOMER
.
Outputs
All input properties are implicitly available as output properties. Additionally, the Remediation resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Remediation
Id string - Remediation ID.
- Id string
- The provider-assigned unique ID for this managed resource.
- Remediation
Id string - Remediation ID.
- id String
- The provider-assigned unique ID for this managed resource.
- remediation
Id String - Remediation ID.
- id string
- The provider-assigned unique ID for this managed resource.
- remediation
Id string - Remediation ID.
- id str
- The provider-assigned unique ID for this managed resource.
- remediation_
id str - Remediation ID.
- id String
- The provider-assigned unique ID for this managed resource.
- remediation
Id String - Remediation ID.
Look up Existing Remediation Resource
Get an existing Remediation resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: RemediationState, opts?: CustomResourceOptions): Remediation
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
config_rule_id: Optional[str] = None,
invoke_type: Optional[str] = None,
params: Optional[str] = None,
remediation_id: Optional[str] = None,
remediation_source_type: Optional[str] = None,
remediation_template_id: Optional[str] = None,
remediation_type: Optional[str] = None) -> Remediation
func GetRemediation(ctx *Context, name string, id IDInput, state *RemediationState, opts ...ResourceOption) (*Remediation, error)
public static Remediation Get(string name, Input<string> id, RemediationState? state, CustomResourceOptions? opts = null)
public static Remediation get(String name, Output<String> id, RemediationState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Config
Rule stringId - Rule ID.
- Invoke
Type string - Execution type, valid values:
Manual
,Automatic
. - Params string
- Remediation parameter.
- Remediation
Id string - Remediation ID.
- Remediation
Source stringType - Remediation resource type, valid values:
ALIYUN
,CUSTOMER
. - Remediation
Template stringId - Remediation template ID.
- Remediation
Type string Remediation type, valid values:
OOS
,FC
.The following arguments will be discarded. Please use new fields as soon as possible:
- Config
Rule stringId - Rule ID.
- Invoke
Type string - Execution type, valid values:
Manual
,Automatic
. - Params string
- Remediation parameter.
- Remediation
Id string - Remediation ID.
- Remediation
Source stringType - Remediation resource type, valid values:
ALIYUN
,CUSTOMER
. - Remediation
Template stringId - Remediation template ID.
- Remediation
Type string Remediation type, valid values:
OOS
,FC
.The following arguments will be discarded. Please use new fields as soon as possible:
- config
Rule StringId - Rule ID.
- invoke
Type String - Execution type, valid values:
Manual
,Automatic
. - params String
- Remediation parameter.
- remediation
Id String - Remediation ID.
- remediation
Source StringType - Remediation resource type, valid values:
ALIYUN
,CUSTOMER
. - remediation
Template StringId - Remediation template ID.
- remediation
Type String Remediation type, valid values:
OOS
,FC
.The following arguments will be discarded. Please use new fields as soon as possible:
- config
Rule stringId - Rule ID.
- invoke
Type string - Execution type, valid values:
Manual
,Automatic
. - params string
- Remediation parameter.
- remediation
Id string - Remediation ID.
- remediation
Source stringType - Remediation resource type, valid values:
ALIYUN
,CUSTOMER
. - remediation
Template stringId - Remediation template ID.
- remediation
Type string Remediation type, valid values:
OOS
,FC
.The following arguments will be discarded. Please use new fields as soon as possible:
- config_
rule_ strid - Rule ID.
- invoke_
type str - Execution type, valid values:
Manual
,Automatic
. - params str
- Remediation parameter.
- remediation_
id str - Remediation ID.
- remediation_
source_ strtype - Remediation resource type, valid values:
ALIYUN
,CUSTOMER
. - remediation_
template_ strid - Remediation template ID.
- remediation_
type str Remediation type, valid values:
OOS
,FC
.The following arguments will be discarded. Please use new fields as soon as possible:
- config
Rule StringId - Rule ID.
- invoke
Type String - Execution type, valid values:
Manual
,Automatic
. - params String
- Remediation parameter.
- remediation
Id String - Remediation ID.
- remediation
Source StringType - Remediation resource type, valid values:
ALIYUN
,CUSTOMER
. - remediation
Template StringId - Remediation template ID.
- remediation
Type String Remediation type, valid values:
OOS
,FC
.The following arguments will be discarded. Please use new fields as soon as possible:
Import
Config Remediation can be imported using the id, e.g.
$ pulumi import alicloud:cfg/remediation:Remediation example <id>
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.