1. Packages
  2. Alicloud Provider
  3. API Docs
  4. mongodb
  5. AuditPolicy
Alibaba Cloud v3.62.1 published on Monday, Sep 16, 2024 by Pulumi

alicloud.mongodb.AuditPolicy

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.62.1 published on Monday, Sep 16, 2024 by Pulumi

    Provides a MongoDB Audit Policy resource.

    For information about MongoDB Audit Policy and how to use it, see What is Audit Policy.

    NOTE: Available since v1.148.0.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    const default = alicloud.mongodb.getZones({});
    const index = _default.then(_default => _default.zones).length.then(length => length - 1);
    const zoneId = _default.then(_default => _default.zones[index].id);
    const defaultNetwork = new alicloud.vpc.Network("default", {
        vpcName: name,
        cidrBlock: "172.17.3.0/24",
    });
    const defaultSwitch = new alicloud.vpc.Switch("default", {
        vswitchName: name,
        cidrBlock: "172.17.3.0/24",
        vpcId: defaultNetwork.id,
        zoneId: zoneId,
    });
    const defaultInstance = new alicloud.mongodb.Instance("default", {
        engineVersion: "4.2",
        dbInstanceClass: "dds.mongo.mid",
        dbInstanceStorage: 10,
        vswitchId: defaultSwitch.id,
        securityIpLists: [
            "10.168.1.12",
            "100.69.7.112",
        ],
        name: name,
        tags: {
            Created: "TF",
            For: "example",
        },
    });
    const defaultAuditPolicy = new alicloud.mongodb.AuditPolicy("default", {
        dbInstanceId: defaultInstance.id,
        auditStatus: "disabled",
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default = alicloud.mongodb.get_zones()
    index = len(default.zones) - 1
    zone_id = default.zones[index].id
    default_network = alicloud.vpc.Network("default",
        vpc_name=name,
        cidr_block="172.17.3.0/24")
    default_switch = alicloud.vpc.Switch("default",
        vswitch_name=name,
        cidr_block="172.17.3.0/24",
        vpc_id=default_network.id,
        zone_id=zone_id)
    default_instance = alicloud.mongodb.Instance("default",
        engine_version="4.2",
        db_instance_class="dds.mongo.mid",
        db_instance_storage=10,
        vswitch_id=default_switch.id,
        security_ip_lists=[
            "10.168.1.12",
            "100.69.7.112",
        ],
        name=name,
        tags={
            "Created": "TF",
            "For": "example",
        })
    default_audit_policy = alicloud.mongodb.AuditPolicy("default",
        db_instance_id=default_instance.id,
        audit_status="disabled")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/mongodb"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
    	"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 := "terraform-example"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		_default, err := mongodb.GetZones(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		index := pulumi.Float64(len(_default.Zones)) - 1
    		zoneId := _default.Zones[index].Id
    		defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
    			VpcName:   pulumi.String(name),
    			CidrBlock: pulumi.String("172.17.3.0/24"),
    		})
    		if err != nil {
    			return err
    		}
    		defaultSwitch, err := vpc.NewSwitch(ctx, "default", &vpc.SwitchArgs{
    			VswitchName: pulumi.String(name),
    			CidrBlock:   pulumi.String("172.17.3.0/24"),
    			VpcId:       defaultNetwork.ID(),
    			ZoneId:      pulumi.String(zoneId),
    		})
    		if err != nil {
    			return err
    		}
    		defaultInstance, err := mongodb.NewInstance(ctx, "default", &mongodb.InstanceArgs{
    			EngineVersion:     pulumi.String("4.2"),
    			DbInstanceClass:   pulumi.String("dds.mongo.mid"),
    			DbInstanceStorage: pulumi.Int(10),
    			VswitchId:         defaultSwitch.ID(),
    			SecurityIpLists: pulumi.StringArray{
    				pulumi.String("10.168.1.12"),
    				pulumi.String("100.69.7.112"),
    			},
    			Name: pulumi.String(name),
    			Tags: pulumi.StringMap{
    				"Created": pulumi.String("TF"),
    				"For":     pulumi.String("example"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = mongodb.NewAuditPolicy(ctx, "default", &mongodb.AuditPolicyArgs{
    			DbInstanceId: defaultInstance.ID(),
    			AuditStatus:  pulumi.String("disabled"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var @default = AliCloud.MongoDB.GetZones.Invoke();
    
        var index = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones)).Length.Apply(length => length - 1);
    
        var zoneId = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones)[index].Id);
    
        var defaultNetwork = new AliCloud.Vpc.Network("default", new()
        {
            VpcName = name,
            CidrBlock = "172.17.3.0/24",
        });
    
        var defaultSwitch = new AliCloud.Vpc.Switch("default", new()
        {
            VswitchName = name,
            CidrBlock = "172.17.3.0/24",
            VpcId = defaultNetwork.Id,
            ZoneId = zoneId,
        });
    
        var defaultInstance = new AliCloud.MongoDB.Instance("default", new()
        {
            EngineVersion = "4.2",
            DbInstanceClass = "dds.mongo.mid",
            DbInstanceStorage = 10,
            VswitchId = defaultSwitch.Id,
            SecurityIpLists = new[]
            {
                "10.168.1.12",
                "100.69.7.112",
            },
            Name = name,
            Tags = 
            {
                { "Created", "TF" },
                { "For", "example" },
            },
        });
    
        var defaultAuditPolicy = new AliCloud.MongoDB.AuditPolicy("default", new()
        {
            DbInstanceId = defaultInstance.Id,
            AuditStatus = "disabled",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.mongodb.MongodbFunctions;
    import com.pulumi.alicloud.mongodb.inputs.GetZonesArgs;
    import com.pulumi.alicloud.vpc.Network;
    import com.pulumi.alicloud.vpc.NetworkArgs;
    import com.pulumi.alicloud.vpc.Switch;
    import com.pulumi.alicloud.vpc.SwitchArgs;
    import com.pulumi.alicloud.mongodb.Instance;
    import com.pulumi.alicloud.mongodb.InstanceArgs;
    import com.pulumi.alicloud.mongodb.AuditPolicy;
    import com.pulumi.alicloud.mongodb.AuditPolicyArgs;
    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("terraform-example");
            final var default = MongodbFunctions.getZones();
    
            final var index = default_.zones().length() - 1;
    
            final var zoneId = default_.zones()[index].id();
    
            var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
                .vpcName(name)
                .cidrBlock("172.17.3.0/24")
                .build());
    
            var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
                .vswitchName(name)
                .cidrBlock("172.17.3.0/24")
                .vpcId(defaultNetwork.id())
                .zoneId(zoneId)
                .build());
    
            var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()
                .engineVersion("4.2")
                .dbInstanceClass("dds.mongo.mid")
                .dbInstanceStorage(10)
                .vswitchId(defaultSwitch.id())
                .securityIpLists(            
                    "10.168.1.12",
                    "100.69.7.112")
                .name(name)
                .tags(Map.ofEntries(
                    Map.entry("Created", "TF"),
                    Map.entry("For", "example")
                ))
                .build());
    
            var defaultAuditPolicy = new AuditPolicy("defaultAuditPolicy", AuditPolicyArgs.builder()
                .dbInstanceId(defaultInstance.id())
                .auditStatus("disabled")
                .build());
    
        }
    }
    
    Coming soon!
    

    Create AuditPolicy Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new AuditPolicy(name: string, args: AuditPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def AuditPolicy(resource_name: str,
                    args: AuditPolicyArgs,
                    opts: Optional[ResourceOptions] = None)
    
    @overload
    def AuditPolicy(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    audit_status: Optional[str] = None,
                    db_instance_id: Optional[str] = None,
                    storage_period: Optional[int] = None)
    func NewAuditPolicy(ctx *Context, name string, args AuditPolicyArgs, opts ...ResourceOption) (*AuditPolicy, error)
    public AuditPolicy(string name, AuditPolicyArgs args, CustomResourceOptions? opts = null)
    public AuditPolicy(String name, AuditPolicyArgs args)
    public AuditPolicy(String name, AuditPolicyArgs args, CustomResourceOptions options)
    
    type: alicloud:mongodb:AuditPolicy
    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 AuditPolicyArgs
    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 AuditPolicyArgs
    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 AuditPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args AuditPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args AuditPolicyArgs
    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 auditPolicyResource = new AliCloud.MongoDB.AuditPolicy("auditPolicyResource", new()
    {
        AuditStatus = "string",
        DbInstanceId = "string",
        StoragePeriod = 0,
    });
    
    example, err := mongodb.NewAuditPolicy(ctx, "auditPolicyResource", &mongodb.AuditPolicyArgs{
    	AuditStatus:   pulumi.String("string"),
    	DbInstanceId:  pulumi.String("string"),
    	StoragePeriod: pulumi.Int(0),
    })
    
    var auditPolicyResource = new AuditPolicy("auditPolicyResource", AuditPolicyArgs.builder()
        .auditStatus("string")
        .dbInstanceId("string")
        .storagePeriod(0)
        .build());
    
    audit_policy_resource = alicloud.mongodb.AuditPolicy("auditPolicyResource",
        audit_status="string",
        db_instance_id="string",
        storage_period=0)
    
    const auditPolicyResource = new alicloud.mongodb.AuditPolicy("auditPolicyResource", {
        auditStatus: "string",
        dbInstanceId: "string",
        storagePeriod: 0,
    });
    
    type: alicloud:mongodb:AuditPolicy
    properties:
        auditStatus: string
        dbInstanceId: string
        storagePeriod: 0
    

    AuditPolicy 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 AuditPolicy resource accepts the following input properties:

    AuditStatus string
    The status of the audit log. Valid values: disabled, enable.
    DbInstanceId string
    The ID of the instance.
    StoragePeriod int
    The retention period of audit logs. Valid values: 1 to 30. Default value: 30.
    AuditStatus string
    The status of the audit log. Valid values: disabled, enable.
    DbInstanceId string
    The ID of the instance.
    StoragePeriod int
    The retention period of audit logs. Valid values: 1 to 30. Default value: 30.
    auditStatus String
    The status of the audit log. Valid values: disabled, enable.
    dbInstanceId String
    The ID of the instance.
    storagePeriod Integer
    The retention period of audit logs. Valid values: 1 to 30. Default value: 30.
    auditStatus string
    The status of the audit log. Valid values: disabled, enable.
    dbInstanceId string
    The ID of the instance.
    storagePeriod number
    The retention period of audit logs. Valid values: 1 to 30. Default value: 30.
    audit_status str
    The status of the audit log. Valid values: disabled, enable.
    db_instance_id str
    The ID of the instance.
    storage_period int
    The retention period of audit logs. Valid values: 1 to 30. Default value: 30.
    auditStatus String
    The status of the audit log. Valid values: disabled, enable.
    dbInstanceId String
    The ID of the instance.
    storagePeriod Number
    The retention period of audit logs. Valid values: 1 to 30. Default value: 30.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the AuditPolicy resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing AuditPolicy Resource

    Get an existing AuditPolicy 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?: AuditPolicyState, opts?: CustomResourceOptions): AuditPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            audit_status: Optional[str] = None,
            db_instance_id: Optional[str] = None,
            storage_period: Optional[int] = None) -> AuditPolicy
    func GetAuditPolicy(ctx *Context, name string, id IDInput, state *AuditPolicyState, opts ...ResourceOption) (*AuditPolicy, error)
    public static AuditPolicy Get(string name, Input<string> id, AuditPolicyState? state, CustomResourceOptions? opts = null)
    public static AuditPolicy get(String name, Output<String> id, AuditPolicyState 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.
    The following state arguments are supported:
    AuditStatus string
    The status of the audit log. Valid values: disabled, enable.
    DbInstanceId string
    The ID of the instance.
    StoragePeriod int
    The retention period of audit logs. Valid values: 1 to 30. Default value: 30.
    AuditStatus string
    The status of the audit log. Valid values: disabled, enable.
    DbInstanceId string
    The ID of the instance.
    StoragePeriod int
    The retention period of audit logs. Valid values: 1 to 30. Default value: 30.
    auditStatus String
    The status of the audit log. Valid values: disabled, enable.
    dbInstanceId String
    The ID of the instance.
    storagePeriod Integer
    The retention period of audit logs. Valid values: 1 to 30. Default value: 30.
    auditStatus string
    The status of the audit log. Valid values: disabled, enable.
    dbInstanceId string
    The ID of the instance.
    storagePeriod number
    The retention period of audit logs. Valid values: 1 to 30. Default value: 30.
    audit_status str
    The status of the audit log. Valid values: disabled, enable.
    db_instance_id str
    The ID of the instance.
    storage_period int
    The retention period of audit logs. Valid values: 1 to 30. Default value: 30.
    auditStatus String
    The status of the audit log. Valid values: disabled, enable.
    dbInstanceId String
    The ID of the instance.
    storagePeriod Number
    The retention period of audit logs. Valid values: 1 to 30. Default value: 30.

    Import

    MongoDB Audit Policy can be imported using the id, e.g.

    $ pulumi import alicloud:mongodb/auditPolicy:AuditPolicy example <db_instance_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.
    alicloud logo
    Alibaba Cloud v3.62.1 published on Monday, Sep 16, 2024 by Pulumi