alicloud.mongodb.AuditPolicy
Explore with Pulumi AI
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
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 defaultZones = AliCloud.MongoDB.GetZones.Invoke();
var index = defaultZones.Apply(getZonesResult => getZonesResult.Zones).Length.Apply(length => length - 1);
var zoneId = defaultZones.Apply(getZonesResult => getZonesResult.Zones)[index].Id;
var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new()
{
VpcName = name,
CidrBlock = "172.17.3.0/24",
});
var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new()
{
VswitchName = name,
CidrBlock = "172.17.3.0/24",
VpcId = defaultNetwork.Id,
ZoneId = zoneId,
});
var defaultInstance = new AliCloud.MongoDB.Instance("defaultInstance", new()
{
EngineVersion = "4.2",
DbInstanceClass = "dds.mongo.mid",
DbInstanceStorage = 10,
VswitchId = defaultSwitch.Id,
SecurityIpLists = new[]
{
"10.168.1.12",
"100.69.7.112",
},
Tags =
{
{ "Created", "TF" },
{ "For", "example" },
},
});
var defaultAuditPolicy = new AliCloud.MongoDB.AuditPolicy("defaultAuditPolicy", new()
{
DbInstanceId = defaultInstance.Id,
AuditStatus = "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
}
defaultZones, err := mongodb.GetZones(ctx, nil, nil)
if err != nil {
return err
}
index := len(defaultZones.Zones) - 1
zoneId := defaultZones.Zones[index].Id
defaultNetwork, err := vpc.NewNetwork(ctx, "defaultNetwork", &vpc.NetworkArgs{
VpcName: pulumi.String(name),
CidrBlock: pulumi.String("172.17.3.0/24"),
})
if err != nil {
return err
}
defaultSwitch, err := vpc.NewSwitch(ctx, "defaultSwitch", &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, "defaultInstance", &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"),
},
Tags: pulumi.Map{
"Created": pulumi.Any("TF"),
"For": pulumi.Any("example"),
},
})
if err != nil {
return err
}
_, err = mongodb.NewAuditPolicy(ctx, "defaultAuditPolicy", &mongodb.AuditPolicyArgs{
DbInstanceId: defaultInstance.ID(),
AuditStatus: pulumi.String("disabled"),
})
if err != nil {
return err
}
return nil
})
}
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 defaultZones = MongodbFunctions.getZones();
final var index = defaultZones.applyValue(getZonesResult -> getZonesResult.zones()).length() - 1;
final var zoneId = defaultZones.applyValue(getZonesResult -> getZonesResult.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")
.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());
}
}
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform-example"
default_zones = alicloud.mongodb.get_zones()
index = len(default_zones.zones) - 1
zone_id = default_zones.zones[index].id
default_network = alicloud.vpc.Network("defaultNetwork",
vpc_name=name,
cidr_block="172.17.3.0/24")
default_switch = alicloud.vpc.Switch("defaultSwitch",
vswitch_name=name,
cidr_block="172.17.3.0/24",
vpc_id=default_network.id,
zone_id=zone_id)
default_instance = alicloud.mongodb.Instance("defaultInstance",
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",
],
tags={
"Created": "TF",
"For": "example",
})
default_audit_policy = alicloud.mongodb.AuditPolicy("defaultAuditPolicy",
db_instance_id=default_instance.id,
audit_status="disabled")
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 defaultZones = alicloud.mongodb.getZones({});
const index = defaultZones.then(defaultZones => defaultZones.zones).length.then(length => length - 1);
const zoneId = defaultZones.then(defaultZones => defaultZones.zones[index].id);
const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {
vpcName: name,
cidrBlock: "172.17.3.0/24",
});
const defaultSwitch = new alicloud.vpc.Switch("defaultSwitch", {
vswitchName: name,
cidrBlock: "172.17.3.0/24",
vpcId: defaultNetwork.id,
zoneId: zoneId,
});
const defaultInstance = new alicloud.mongodb.Instance("defaultInstance", {
engineVersion: "4.2",
dbInstanceClass: "dds.mongo.mid",
dbInstanceStorage: 10,
vswitchId: defaultSwitch.id,
securityIpLists: [
"10.168.1.12",
"100.69.7.112",
],
tags: {
Created: "TF",
For: "example",
},
});
const defaultAuditPolicy = new alicloud.mongodb.AuditPolicy("defaultAuditPolicy", {
dbInstanceId: defaultInstance.id,
auditStatus: "disabled",
});
Coming soon!
Create AuditPolicy Resource
new AuditPolicy(name: string, args: AuditPolicyArgs, opts?: CustomResourceOptions);
@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)
@overload
def AuditPolicy(resource_name: str,
args: AuditPolicyArgs,
opts: Optional[ResourceOptions] = 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.
- 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.
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:
- Audit
Status string The status of the audit log. Valid values:
disabled
,enable
.- Db
Instance stringId The ID of the instance.
- Storage
Period int The retention period of audit logs. Valid values:
1
to30
. Default value:30
.
- Audit
Status string The status of the audit log. Valid values:
disabled
,enable
.- Db
Instance stringId The ID of the instance.
- Storage
Period int The retention period of audit logs. Valid values:
1
to30
. Default value:30
.
- audit
Status String The status of the audit log. Valid values:
disabled
,enable
.- db
Instance StringId The ID of the instance.
- storage
Period Integer The retention period of audit logs. Valid values:
1
to30
. Default value:30
.
- audit
Status string The status of the audit log. Valid values:
disabled
,enable
.- db
Instance stringId The ID of the instance.
- storage
Period number The retention period of audit logs. Valid values:
1
to30
. Default value:30
.
- audit_
status str The status of the audit log. Valid values:
disabled
,enable
.- db_
instance_ strid The ID of the instance.
- storage_
period int The retention period of audit logs. Valid values:
1
to30
. Default value:30
.
- audit
Status String The status of the audit log. Valid values:
disabled
,enable
.- db
Instance StringId The ID of the instance.
- storage
Period Number The retention period of audit logs. Valid values:
1
to30
. 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.
- Audit
Status string The status of the audit log. Valid values:
disabled
,enable
.- Db
Instance stringId The ID of the instance.
- Storage
Period int The retention period of audit logs. Valid values:
1
to30
. Default value:30
.
- Audit
Status string The status of the audit log. Valid values:
disabled
,enable
.- Db
Instance stringId The ID of the instance.
- Storage
Period int The retention period of audit logs. Valid values:
1
to30
. Default value:30
.
- audit
Status String The status of the audit log. Valid values:
disabled
,enable
.- db
Instance StringId The ID of the instance.
- storage
Period Integer The retention period of audit logs. Valid values:
1
to30
. Default value:30
.
- audit
Status string The status of the audit log. Valid values:
disabled
,enable
.- db
Instance stringId The ID of the instance.
- storage
Period number The retention period of audit logs. Valid values:
1
to30
. Default value:30
.
- audit_
status str The status of the audit log. Valid values:
disabled
,enable
.- db_
instance_ strid The ID of the instance.
- storage_
period int The retention period of audit logs. Valid values:
1
to30
. Default value:30
.
- audit
Status String The status of the audit log. Valid values:
disabled
,enable
.- db
Instance StringId The ID of the instance.
- storage
Period Number The retention period of audit logs. Valid values:
1
to30
. 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>
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
alicloud
Terraform Provider.