# coding=utf-8
# *** 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! ***

import copy
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
from .. import _utilities

__all__ = ['TriggerArgs', 'Trigger']

@pulumi.input_type
class TriggerArgs:
    def __init__(__self__, *,
                 function: pulumi.Input[str],
                 service: pulumi.Input[str],
                 type: pulumi.Input[str],
                 config: Optional[pulumi.Input[str]] = None,
                 config_mns: Optional[pulumi.Input[str]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 name_prefix: Optional[pulumi.Input[str]] = None,
                 role: Optional[pulumi.Input[str]] = None,
                 source_arn: Optional[pulumi.Input[str]] = None):
        """
        The set of arguments for constructing a Trigger resource.
        :param pulumi.Input[str] function: The Function Compute function name.
        :param pulumi.Input[str] service: The Function Compute service name.
        :param pulumi.Input[str] type: The Type of the trigger. Valid values: ["oss", "log", "timer", "http", "mns_topic", "cdn_events", "eventbridge"].
               
               > **NOTE:** Config does not support modification when type is mns_topic.
               > **NOTE:** type = cdn_events, available in 1.47.0+.
               > **NOTE:** type = eventbridge, available in 1.173.0+.
        :param pulumi.Input[str] config: The config of Function Compute trigger.It is valid when `type` is not "mns_topic".See [Configure triggers and events](https://www.alibabacloud.com/help/doc-detail/70140.htm) for more details.
        :param pulumi.Input[str] config_mns: The config of Function Compute trigger when the type is "mns_topic".It is conflict with `config`.
        :param pulumi.Input[str] name: The Function Compute trigger name. It is the only in one service and is conflict with "name_prefix".
        :param pulumi.Input[str] name_prefix: Setting a prefix to get a only trigger name. It is conflict with "name".
        :param pulumi.Input[str] role: RAM role arn attached to the Function Compute trigger. Role used by the event source to call the function. The value format is "acs:ram::$account-id:role/$role-name". See [Create a trigger](https://www.alibabacloud.com/help/doc-detail/53102.htm) for more details.
        :param pulumi.Input[str] source_arn: Event source resource address. See [Create a trigger](https://www.alibabacloud.com/help/doc-detail/53102.htm) for more details.
        """
        pulumi.set(__self__, "function", function)
        pulumi.set(__self__, "service", service)
        pulumi.set(__self__, "type", type)
        if config is not None:
            pulumi.set(__self__, "config", config)
        if config_mns is not None:
            pulumi.set(__self__, "config_mns", config_mns)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if name_prefix is not None:
            pulumi.set(__self__, "name_prefix", name_prefix)
        if role is not None:
            pulumi.set(__self__, "role", role)
        if source_arn is not None:
            pulumi.set(__self__, "source_arn", source_arn)

    @property
    @pulumi.getter
    def function(self) -> pulumi.Input[str]:
        """
        The Function Compute function name.
        """
        return pulumi.get(self, "function")

    @function.setter
    def function(self, value: pulumi.Input[str]):
        pulumi.set(self, "function", value)

    @property
    @pulumi.getter
    def service(self) -> pulumi.Input[str]:
        """
        The Function Compute service name.
        """
        return pulumi.get(self, "service")

    @service.setter
    def service(self, value: pulumi.Input[str]):
        pulumi.set(self, "service", value)

    @property
    @pulumi.getter
    def type(self) -> pulumi.Input[str]:
        """
        The Type of the trigger. Valid values: ["oss", "log", "timer", "http", "mns_topic", "cdn_events", "eventbridge"].

        > **NOTE:** Config does not support modification when type is mns_topic.
        > **NOTE:** type = cdn_events, available in 1.47.0+.
        > **NOTE:** type = eventbridge, available in 1.173.0+.
        """
        return pulumi.get(self, "type")

    @type.setter
    def type(self, value: pulumi.Input[str]):
        pulumi.set(self, "type", value)

    @property
    @pulumi.getter
    def config(self) -> Optional[pulumi.Input[str]]:
        """
        The config of Function Compute trigger.It is valid when `type` is not "mns_topic".See [Configure triggers and events](https://www.alibabacloud.com/help/doc-detail/70140.htm) for more details.
        """
        return pulumi.get(self, "config")

    @config.setter
    def config(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "config", value)

    @property
    @pulumi.getter(name="configMns")
    def config_mns(self) -> Optional[pulumi.Input[str]]:
        """
        The config of Function Compute trigger when the type is "mns_topic".It is conflict with `config`.
        """
        return pulumi.get(self, "config_mns")

    @config_mns.setter
    def config_mns(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "config_mns", value)

    @property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[str]]:
        """
        The Function Compute trigger name. It is the only in one service and is conflict with "name_prefix".
        """
        return pulumi.get(self, "name")

    @name.setter
    def name(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "name", value)

    @property
    @pulumi.getter(name="namePrefix")
    def name_prefix(self) -> Optional[pulumi.Input[str]]:
        """
        Setting a prefix to get a only trigger name. It is conflict with "name".
        """
        return pulumi.get(self, "name_prefix")

    @name_prefix.setter
    def name_prefix(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "name_prefix", value)

    @property
    @pulumi.getter
    def role(self) -> Optional[pulumi.Input[str]]:
        """
        RAM role arn attached to the Function Compute trigger. Role used by the event source to call the function. The value format is "acs:ram::$account-id:role/$role-name". See [Create a trigger](https://www.alibabacloud.com/help/doc-detail/53102.htm) for more details.
        """
        return pulumi.get(self, "role")

    @role.setter
    def role(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "role", value)

    @property
    @pulumi.getter(name="sourceArn")
    def source_arn(self) -> Optional[pulumi.Input[str]]:
        """
        Event source resource address. See [Create a trigger](https://www.alibabacloud.com/help/doc-detail/53102.htm) for more details.
        """
        return pulumi.get(self, "source_arn")

    @source_arn.setter
    def source_arn(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "source_arn", value)


@pulumi.input_type
class _TriggerState:
    def __init__(__self__, *,
                 config: Optional[pulumi.Input[str]] = None,
                 config_mns: Optional[pulumi.Input[str]] = None,
                 function: Optional[pulumi.Input[str]] = None,
                 last_modified: Optional[pulumi.Input[str]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 name_prefix: Optional[pulumi.Input[str]] = None,
                 role: Optional[pulumi.Input[str]] = None,
                 service: Optional[pulumi.Input[str]] = None,
                 source_arn: Optional[pulumi.Input[str]] = None,
                 trigger_id: Optional[pulumi.Input[str]] = None,
                 type: Optional[pulumi.Input[str]] = None):
        """
        Input properties used for looking up and filtering Trigger resources.
        :param pulumi.Input[str] config: The config of Function Compute trigger.It is valid when `type` is not "mns_topic".See [Configure triggers and events](https://www.alibabacloud.com/help/doc-detail/70140.htm) for more details.
        :param pulumi.Input[str] config_mns: The config of Function Compute trigger when the type is "mns_topic".It is conflict with `config`.
        :param pulumi.Input[str] function: The Function Compute function name.
        :param pulumi.Input[str] last_modified: The date this resource was last modified.
        :param pulumi.Input[str] name: The Function Compute trigger name. It is the only in one service and is conflict with "name_prefix".
        :param pulumi.Input[str] name_prefix: Setting a prefix to get a only trigger name. It is conflict with "name".
        :param pulumi.Input[str] role: RAM role arn attached to the Function Compute trigger. Role used by the event source to call the function. The value format is "acs:ram::$account-id:role/$role-name". See [Create a trigger](https://www.alibabacloud.com/help/doc-detail/53102.htm) for more details.
        :param pulumi.Input[str] service: The Function Compute service name.
        :param pulumi.Input[str] source_arn: Event source resource address. See [Create a trigger](https://www.alibabacloud.com/help/doc-detail/53102.htm) for more details.
        :param pulumi.Input[str] trigger_id: The Function Compute trigger ID.
        :param pulumi.Input[str] type: The Type of the trigger. Valid values: ["oss", "log", "timer", "http", "mns_topic", "cdn_events", "eventbridge"].
               
               > **NOTE:** Config does not support modification when type is mns_topic.
               > **NOTE:** type = cdn_events, available in 1.47.0+.
               > **NOTE:** type = eventbridge, available in 1.173.0+.
        """
        if config is not None:
            pulumi.set(__self__, "config", config)
        if config_mns is not None:
            pulumi.set(__self__, "config_mns", config_mns)
        if function is not None:
            pulumi.set(__self__, "function", function)
        if last_modified is not None:
            pulumi.set(__self__, "last_modified", last_modified)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if name_prefix is not None:
            pulumi.set(__self__, "name_prefix", name_prefix)
        if role is not None:
            pulumi.set(__self__, "role", role)
        if service is not None:
            pulumi.set(__self__, "service", service)
        if source_arn is not None:
            pulumi.set(__self__, "source_arn", source_arn)
        if trigger_id is not None:
            pulumi.set(__self__, "trigger_id", trigger_id)
        if type is not None:
            pulumi.set(__self__, "type", type)

    @property
    @pulumi.getter
    def config(self) -> Optional[pulumi.Input[str]]:
        """
        The config of Function Compute trigger.It is valid when `type` is not "mns_topic".See [Configure triggers and events](https://www.alibabacloud.com/help/doc-detail/70140.htm) for more details.
        """
        return pulumi.get(self, "config")

    @config.setter
    def config(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "config", value)

    @property
    @pulumi.getter(name="configMns")
    def config_mns(self) -> Optional[pulumi.Input[str]]:
        """
        The config of Function Compute trigger when the type is "mns_topic".It is conflict with `config`.
        """
        return pulumi.get(self, "config_mns")

    @config_mns.setter
    def config_mns(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "config_mns", value)

    @property
    @pulumi.getter
    def function(self) -> Optional[pulumi.Input[str]]:
        """
        The Function Compute function name.
        """
        return pulumi.get(self, "function")

    @function.setter
    def function(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "function", value)

    @property
    @pulumi.getter(name="lastModified")
    def last_modified(self) -> Optional[pulumi.Input[str]]:
        """
        The date this resource was last modified.
        """
        return pulumi.get(self, "last_modified")

    @last_modified.setter
    def last_modified(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "last_modified", value)

    @property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[str]]:
        """
        The Function Compute trigger name. It is the only in one service and is conflict with "name_prefix".
        """
        return pulumi.get(self, "name")

    @name.setter
    def name(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "name", value)

    @property
    @pulumi.getter(name="namePrefix")
    def name_prefix(self) -> Optional[pulumi.Input[str]]:
        """
        Setting a prefix to get a only trigger name. It is conflict with "name".
        """
        return pulumi.get(self, "name_prefix")

    @name_prefix.setter
    def name_prefix(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "name_prefix", value)

    @property
    @pulumi.getter
    def role(self) -> Optional[pulumi.Input[str]]:
        """
        RAM role arn attached to the Function Compute trigger. Role used by the event source to call the function. The value format is "acs:ram::$account-id:role/$role-name". See [Create a trigger](https://www.alibabacloud.com/help/doc-detail/53102.htm) for more details.
        """
        return pulumi.get(self, "role")

    @role.setter
    def role(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "role", value)

    @property
    @pulumi.getter
    def service(self) -> Optional[pulumi.Input[str]]:
        """
        The Function Compute service name.
        """
        return pulumi.get(self, "service")

    @service.setter
    def service(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "service", value)

    @property
    @pulumi.getter(name="sourceArn")
    def source_arn(self) -> Optional[pulumi.Input[str]]:
        """
        Event source resource address. See [Create a trigger](https://www.alibabacloud.com/help/doc-detail/53102.htm) for more details.
        """
        return pulumi.get(self, "source_arn")

    @source_arn.setter
    def source_arn(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "source_arn", value)

    @property
    @pulumi.getter(name="triggerId")
    def trigger_id(self) -> Optional[pulumi.Input[str]]:
        """
        The Function Compute trigger ID.
        """
        return pulumi.get(self, "trigger_id")

    @trigger_id.setter
    def trigger_id(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "trigger_id", value)

    @property
    @pulumi.getter
    def type(self) -> Optional[pulumi.Input[str]]:
        """
        The Type of the trigger. Valid values: ["oss", "log", "timer", "http", "mns_topic", "cdn_events", "eventbridge"].

        > **NOTE:** Config does not support modification when type is mns_topic.
        > **NOTE:** type = cdn_events, available in 1.47.0+.
        > **NOTE:** type = eventbridge, available in 1.173.0+.
        """
        return pulumi.get(self, "type")

    @type.setter
    def type(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "type", value)


class Trigger(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 config: Optional[pulumi.Input[str]] = None,
                 config_mns: Optional[pulumi.Input[str]] = None,
                 function: Optional[pulumi.Input[str]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 name_prefix: Optional[pulumi.Input[str]] = None,
                 role: Optional[pulumi.Input[str]] = None,
                 service: Optional[pulumi.Input[str]] = None,
                 source_arn: Optional[pulumi.Input[str]] = None,
                 type: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        """
        Provides an Alicloud Function Compute Trigger resource. Based on trigger, execute your code in response to events in Alibaba Cloud.
         For information about Service and how to use it, see [What is Function Compute](https://www.alibabacloud.com/help/doc-detail/52895.htm).

        > **NOTE:** The resource requires a provider field 'account_id'. See account_id.

        ## Example Usage

        Basic Usage

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        config = pulumi.Config()
        region = config.get("region")
        if region is None:
            region = "cn-hangzhou"
        account = config.get("account")
        if account is None:
            account = "12345"
        foo_role = alicloud.ram.Role("fooRole",
            document=\"\"\"  {
            "Statement": [
              {
                "Action": "sts:AssumeRole",
                "Effect": "Allow",
                "Principal": {
                  "Service": [
                    "log.aliyuncs.com"
                  ]
                }
              }
            ],
            "Version": "1"
          }
          
        \"\"\",
            description="this is a test",
            force=True)
        foo_role_policy_attachment = alicloud.ram.RolePolicyAttachment("fooRolePolicyAttachment",
            role_name=foo_role.name,
            policy_name="AliyunLogFullAccess",
            policy_type="System")
        foo_trigger = alicloud.fc.Trigger("fooTrigger",
            service="my-fc-service",
            function="hello-world",
            role=foo_role.arn,
            source_arn=f"acs:log:{region}:{account}:project/{alicloud_log_project['foo']['name']}",
            type="log",
            config=\"\"\"    {
                "sourceConfig": {
                    "project": "project-for-fc",
                    "logstore": "project-for-fc"
                },
                "jobConfig": {
                    "maxRetryTime": 3,
                    "triggerInterval": 60
                },
                "functionParameter": {
                    "a": "b",
                    "c": "d"
                },
                "logConfig": {
                    "project": "project-for-fc-log",
                    "logstore": "project-for-fc-log"
                },
                "enable": true
            }
          
        \"\"\",
            opts=pulumi.ResourceOptions(depends_on=[foo_role_policy_attachment]))
        ```

        MNS topic trigger:

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        config = pulumi.Config()
        name = config.get("name")
        if name is None:
            name = "fctriggermnstopic"
        current_region = alicloud.get_regions(current=True)
        current = alicloud.get_account()
        foo_project = alicloud.log.Project("fooProject", description="tf unit test")
        bar = alicloud.log.Store("bar",
            project=foo_project.name,
            retention_period=3000,
            shard_count=1)
        foo_store = alicloud.log.Store("fooStore",
            project=foo_project.name,
            retention_period=3000,
            shard_count=1)
        foo_topic = alicloud.mns.Topic("fooTopic")
        foo_service = alicloud.fc.Service("fooService", internet_access=False)
        foo_bucket = alicloud.oss.Bucket("fooBucket", bucket=name)
        # If you upload the function by OSS Bucket, you need to specify path can't upload by content.
        foo_bucket_object = alicloud.oss.BucketObject("fooBucketObject",
            bucket=foo_bucket.id,
            key="fc/hello.zip",
            source="./hello.zip")
        foo_function = alicloud.fc.Function("fooFunction",
            handler="hello.handler",
            memory_size=512,
            oss_bucket=foo_bucket.id,
            oss_key=foo_bucket_object.key,
            runtime="python2.7",
            service=foo_service.name)
        foo_role = alicloud.ram.Role("fooRole",
            description="this is a test",
            document=\"\"\"  {
            "Statement": [
              {
                "Action": "sts:AssumeRole",
                "Effect": "Allow",
                "Principal": {
                  "Service": [
                    "mns.aliyuncs.com"
                  ]
                }
              }
            ],
            "Version": "1"
          }
          
        \"\"\",
            force=True)
        foo_role_policy_attachment = alicloud.ram.RolePolicyAttachment("fooRolePolicyAttachment",
            policy_name="AliyunMNSNotificationRolePolicy",
            policy_type="System",
            role_name=foo_role.name)
        foo_trigger = alicloud.fc.Trigger("fooTrigger",
            config_mns=\"\"\"  {
            "filterTag":"testTag",
            "notifyContentFormat":"STREAM",
            "notifyStrategy":"BACKOFF_RETRY"
          }
          
        \"\"\",
            function=foo_function.name,
            role=foo_role.arn,
            service=foo_service.name,
            source_arn=foo_topic.name.apply(lambda name: f"acs:mns:{current_region.regions[0].id}:{current.id}:/topics/{name}"),
            type="mns_topic",
            opts=pulumi.ResourceOptions(depends_on=["alicloud_ram_role_policy_attachment.foo"]))
        ```

        CDN events trigger:

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        config = pulumi.Config()
        name = config.get("name")
        if name is None:
            name = "fctriggercdneventsconfig"
        current = alicloud.get_account()
        domain = alicloud.cdn.DomainNew("domain",
            cdn_type="web",
            domain_name=f"{name}.tf.com",
            scope="overseas",
            sources=[alicloud.cdn.DomainNewSourceArgs(
                content="1.1.1.1",
                port=80,
                priority=20,
                type="ipaddr",
                weight=10,
            )])
        foo_service = alicloud.fc.Service("fooService", internet_access=False)
        foo_bucket = alicloud.oss.Bucket("fooBucket", bucket=name)
        # If you upload the function by OSS Bucket, you need to specify path can't upload by content.
        foo_bucket_object = alicloud.oss.BucketObject("fooBucketObject",
            bucket=foo_bucket.id,
            key="fc/hello.zip",
            source="./hello.zip")
        foo_function = alicloud.fc.Function("fooFunction",
            handler="hello.handler",
            memory_size=512,
            oss_bucket=foo_bucket.id,
            oss_key=foo_bucket_object.key,
            runtime="python2.7",
            service=foo_service.name)
        foo_role = alicloud.ram.Role("fooRole",
            description="this is a test",
            document=\"\"\"    {
                "Version": "1",
                "Statement": [
                    {
                        "Action": "cdn:Describe*",
                        "Resource": "*",
                        "Effect": "Allow",
        		        "Principal": {
                        "Service":
                            ["log.aliyuncs.com"]
                        }
                    }
                ]
            }
            
        \"\"\",
            force=True)
        foo_policy = alicloud.ram.Policy("fooPolicy",
            description="this is a test",
            document=\"\"\"    {
                "Version": "1",
                "Statement": [
                {
                    "Action": [
                    "fc:InvokeFunction"
                    ],
                "Resource": [
                    "acs:fc:*:*:services/tf_cdnEvents/functions/*",
                    "acs:fc:*:*:services/tf_cdnEvents.*/functions/*"
                ],
                "Effect": "Allow"
                }
                ]
            }
            
        \"\"\",
            force=True)
        foo_role_policy_attachment = alicloud.ram.RolePolicyAttachment("fooRolePolicyAttachment",
            policy_name=foo_policy.name,
            policy_type="Custom",
            role_name=foo_role.name)
        default = alicloud.fc.Trigger("default",
            config=domain.domain_name.apply(lambda domain_name: f\"\"\"      {{"eventName":"LogFileCreated",
             "eventVersion":"1.0.0",
             "notes":"cdn events trigger",
             "filter":{{
                "domain": ["{domain_name}"]
                }}
            }}

        \"\"\"),
            function=foo_function.name,
            role=foo_role.arn,
            service=foo_service.name,
            source_arn=f"acs:cdn:*:{current.id}",
            type="cdn_events",
            opts=pulumi.ResourceOptions(depends_on=["alicloud_ram_role_policy_attachment.foo"]))
        ```

        EventBridge trigger:

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        config = pulumi.Config()
        name = config.get("name")
        if name is None:
            name = "fctriggereventbridgeconfig"
        current = alicloud.get_account()
        # Please make eventbridge available and then assume a specific service-linked role, which refers to https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/event_bridge_service_linked_role
        service_linked_role = alicloud.eventbridge.ServiceLinkedRole("serviceLinkedRole", product_name="AliyunServiceRoleForEventBridgeSendToFC")
        foo_service = alicloud.fc.Service("fooService", internet_access=False)
        foo_bucket = alicloud.oss.Bucket("fooBucket", bucket=name)
        # If you upload the function by OSS Bucket, you need to specify path can't upload by content.
        foo_bucket_object = alicloud.oss.BucketObject("fooBucketObject",
            bucket=foo_bucket.id,
            key="fc/hello.zip",
            source="./hello.zip")
        foo_function = alicloud.fc.Function("fooFunction",
            handler="hello.handler",
            memory_size=512,
            oss_bucket=foo_bucket.id,
            oss_key=foo_bucket_object.key,
            runtime="python2.7",
            service=foo_service.name)
        default = alicloud.fc.Trigger("default",
            config=\"\"\"    {
                "triggerEnable": false,
                "asyncInvocationType": false,
                "eventRuleFilterPattern": "{\\"source\\":[\\"acs.oss\\"],\\"type\\":[\\"oss:BucketCreated:PutBucket\\"]}",
                "eventSourceConfig": {
                    "eventSourceType": "Default"
                }
            }

        \"\"\",
            function=foo_function.name,
            service=foo_service.name,
            type="eventbridge")
        mns = alicloud.fc.Trigger("mns",
            config=\"\"\"    {
                "triggerEnable": false,
                "asyncInvocationType": false,
                "eventRuleFilterPattern": "{}",
                "eventSourceConfig": {
                    "eventSourceType": "MNS",
                    "eventSourceParameters": {
                        "sourceMNSParameters": {
                            "RegionId": "cn-hangzhou",
                            "QueueName": "mns-queue",
                            "IsBase64Decode": true
                        }
                    }
                }
            }

        \"\"\",
            function=foo_function.name,
            service=foo_service.name,
            type="eventbridge")
        rocketmq = alicloud.fc.Trigger("rocketmq",
            config=\"\"\"    {
                "triggerEnable": false,
                "asyncInvocationType": false,
                "eventRuleFilterPattern": "{}",
                "eventSourceConfig": {
                    "eventSourceType": "RocketMQ",
                    "eventSourceParameters": {
                        "sourceRocketMQParameters": {
                            "RegionId": "cn-hangzhou",
                            "InstanceId": "MQ_INST_164901546557****_BAAN****",
                            "GroupID": "GID_group1",
                            "Topic": "mytopic",
                            "Timestamp": 1636597951984,
                            "Tag": "test-tag",
                            "Offset": "CONSUME_FROM_LAST_OFFSET"
                        }
                    }
                }
            }

        \"\"\",
            function=foo_function.name,
            service=foo_service.name,
            type="eventbridge")
        rabbitmq = alicloud.fc.Trigger("rabbitmq",
            config=\"\"\"    {
                "triggerEnable": false,
                "asyncInvocationType": false,
                "eventRuleFilterPattern": "{}",
                "eventSourceConfig": {
                    "eventSourceType": "RabbitMQ",
                    "eventSourceParameters": {
                        "sourceRabbitMQParameters": {
                            "RegionId": "cn-hangzhou",
                            "InstanceId": "amqp-cn-****** ",
                            "VirtualHostName": "test-virtual",
                            "QueueName": "test-queue"
                        }
                    }
                }
            }

        \"\"\",
            function=foo_function.name,
            service=foo_service.name,
            type="eventbridge")
        ```
        ## Module Support

        You can use to the existing fc module
        to create several triggers quickly.

        ## Import

        Function Compute trigger can be imported using the id, e.g.

        ```sh
         $ pulumi import alicloud:fc/trigger:Trigger foo my-fc-service:hello-world:hello-trigger
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] config: The config of Function Compute trigger.It is valid when `type` is not "mns_topic".See [Configure triggers and events](https://www.alibabacloud.com/help/doc-detail/70140.htm) for more details.
        :param pulumi.Input[str] config_mns: The config of Function Compute trigger when the type is "mns_topic".It is conflict with `config`.
        :param pulumi.Input[str] function: The Function Compute function name.
        :param pulumi.Input[str] name: The Function Compute trigger name. It is the only in one service and is conflict with "name_prefix".
        :param pulumi.Input[str] name_prefix: Setting a prefix to get a only trigger name. It is conflict with "name".
        :param pulumi.Input[str] role: RAM role arn attached to the Function Compute trigger. Role used by the event source to call the function. The value format is "acs:ram::$account-id:role/$role-name". See [Create a trigger](https://www.alibabacloud.com/help/doc-detail/53102.htm) for more details.
        :param pulumi.Input[str] service: The Function Compute service name.
        :param pulumi.Input[str] source_arn: Event source resource address. See [Create a trigger](https://www.alibabacloud.com/help/doc-detail/53102.htm) for more details.
        :param pulumi.Input[str] type: The Type of the trigger. Valid values: ["oss", "log", "timer", "http", "mns_topic", "cdn_events", "eventbridge"].
               
               > **NOTE:** Config does not support modification when type is mns_topic.
               > **NOTE:** type = cdn_events, available in 1.47.0+.
               > **NOTE:** type = eventbridge, available in 1.173.0+.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: TriggerArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        Provides an Alicloud Function Compute Trigger resource. Based on trigger, execute your code in response to events in Alibaba Cloud.
         For information about Service and how to use it, see [What is Function Compute](https://www.alibabacloud.com/help/doc-detail/52895.htm).

        > **NOTE:** The resource requires a provider field 'account_id'. See account_id.

        ## Example Usage

        Basic Usage

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        config = pulumi.Config()
        region = config.get("region")
        if region is None:
            region = "cn-hangzhou"
        account = config.get("account")
        if account is None:
            account = "12345"
        foo_role = alicloud.ram.Role("fooRole",
            document=\"\"\"  {
            "Statement": [
              {
                "Action": "sts:AssumeRole",
                "Effect": "Allow",
                "Principal": {
                  "Service": [
                    "log.aliyuncs.com"
                  ]
                }
              }
            ],
            "Version": "1"
          }
          
        \"\"\",
            description="this is a test",
            force=True)
        foo_role_policy_attachment = alicloud.ram.RolePolicyAttachment("fooRolePolicyAttachment",
            role_name=foo_role.name,
            policy_name="AliyunLogFullAccess",
            policy_type="System")
        foo_trigger = alicloud.fc.Trigger("fooTrigger",
            service="my-fc-service",
            function="hello-world",
            role=foo_role.arn,
            source_arn=f"acs:log:{region}:{account}:project/{alicloud_log_project['foo']['name']}",
            type="log",
            config=\"\"\"    {
                "sourceConfig": {
                    "project": "project-for-fc",
                    "logstore": "project-for-fc"
                },
                "jobConfig": {
                    "maxRetryTime": 3,
                    "triggerInterval": 60
                },
                "functionParameter": {
                    "a": "b",
                    "c": "d"
                },
                "logConfig": {
                    "project": "project-for-fc-log",
                    "logstore": "project-for-fc-log"
                },
                "enable": true
            }
          
        \"\"\",
            opts=pulumi.ResourceOptions(depends_on=[foo_role_policy_attachment]))
        ```

        MNS topic trigger:

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        config = pulumi.Config()
        name = config.get("name")
        if name is None:
            name = "fctriggermnstopic"
        current_region = alicloud.get_regions(current=True)
        current = alicloud.get_account()
        foo_project = alicloud.log.Project("fooProject", description="tf unit test")
        bar = alicloud.log.Store("bar",
            project=foo_project.name,
            retention_period=3000,
            shard_count=1)
        foo_store = alicloud.log.Store("fooStore",
            project=foo_project.name,
            retention_period=3000,
            shard_count=1)
        foo_topic = alicloud.mns.Topic("fooTopic")
        foo_service = alicloud.fc.Service("fooService", internet_access=False)
        foo_bucket = alicloud.oss.Bucket("fooBucket", bucket=name)
        # If you upload the function by OSS Bucket, you need to specify path can't upload by content.
        foo_bucket_object = alicloud.oss.BucketObject("fooBucketObject",
            bucket=foo_bucket.id,
            key="fc/hello.zip",
            source="./hello.zip")
        foo_function = alicloud.fc.Function("fooFunction",
            handler="hello.handler",
            memory_size=512,
            oss_bucket=foo_bucket.id,
            oss_key=foo_bucket_object.key,
            runtime="python2.7",
            service=foo_service.name)
        foo_role = alicloud.ram.Role("fooRole",
            description="this is a test",
            document=\"\"\"  {
            "Statement": [
              {
                "Action": "sts:AssumeRole",
                "Effect": "Allow",
                "Principal": {
                  "Service": [
                    "mns.aliyuncs.com"
                  ]
                }
              }
            ],
            "Version": "1"
          }
          
        \"\"\",
            force=True)
        foo_role_policy_attachment = alicloud.ram.RolePolicyAttachment("fooRolePolicyAttachment",
            policy_name="AliyunMNSNotificationRolePolicy",
            policy_type="System",
            role_name=foo_role.name)
        foo_trigger = alicloud.fc.Trigger("fooTrigger",
            config_mns=\"\"\"  {
            "filterTag":"testTag",
            "notifyContentFormat":"STREAM",
            "notifyStrategy":"BACKOFF_RETRY"
          }
          
        \"\"\",
            function=foo_function.name,
            role=foo_role.arn,
            service=foo_service.name,
            source_arn=foo_topic.name.apply(lambda name: f"acs:mns:{current_region.regions[0].id}:{current.id}:/topics/{name}"),
            type="mns_topic",
            opts=pulumi.ResourceOptions(depends_on=["alicloud_ram_role_policy_attachment.foo"]))
        ```

        CDN events trigger:

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        config = pulumi.Config()
        name = config.get("name")
        if name is None:
            name = "fctriggercdneventsconfig"
        current = alicloud.get_account()
        domain = alicloud.cdn.DomainNew("domain",
            cdn_type="web",
            domain_name=f"{name}.tf.com",
            scope="overseas",
            sources=[alicloud.cdn.DomainNewSourceArgs(
                content="1.1.1.1",
                port=80,
                priority=20,
                type="ipaddr",
                weight=10,
            )])
        foo_service = alicloud.fc.Service("fooService", internet_access=False)
        foo_bucket = alicloud.oss.Bucket("fooBucket", bucket=name)
        # If you upload the function by OSS Bucket, you need to specify path can't upload by content.
        foo_bucket_object = alicloud.oss.BucketObject("fooBucketObject",
            bucket=foo_bucket.id,
            key="fc/hello.zip",
            source="./hello.zip")
        foo_function = alicloud.fc.Function("fooFunction",
            handler="hello.handler",
            memory_size=512,
            oss_bucket=foo_bucket.id,
            oss_key=foo_bucket_object.key,
            runtime="python2.7",
            service=foo_service.name)
        foo_role = alicloud.ram.Role("fooRole",
            description="this is a test",
            document=\"\"\"    {
                "Version": "1",
                "Statement": [
                    {
                        "Action": "cdn:Describe*",
                        "Resource": "*",
                        "Effect": "Allow",
        		        "Principal": {
                        "Service":
                            ["log.aliyuncs.com"]
                        }
                    }
                ]
            }
            
        \"\"\",
            force=True)
        foo_policy = alicloud.ram.Policy("fooPolicy",
            description="this is a test",
            document=\"\"\"    {
                "Version": "1",
                "Statement": [
                {
                    "Action": [
                    "fc:InvokeFunction"
                    ],
                "Resource": [
                    "acs:fc:*:*:services/tf_cdnEvents/functions/*",
                    "acs:fc:*:*:services/tf_cdnEvents.*/functions/*"
                ],
                "Effect": "Allow"
                }
                ]
            }
            
        \"\"\",
            force=True)
        foo_role_policy_attachment = alicloud.ram.RolePolicyAttachment("fooRolePolicyAttachment",
            policy_name=foo_policy.name,
            policy_type="Custom",
            role_name=foo_role.name)
        default = alicloud.fc.Trigger("default",
            config=domain.domain_name.apply(lambda domain_name: f\"\"\"      {{"eventName":"LogFileCreated",
             "eventVersion":"1.0.0",
             "notes":"cdn events trigger",
             "filter":{{
                "domain": ["{domain_name}"]
                }}
            }}

        \"\"\"),
            function=foo_function.name,
            role=foo_role.arn,
            service=foo_service.name,
            source_arn=f"acs:cdn:*:{current.id}",
            type="cdn_events",
            opts=pulumi.ResourceOptions(depends_on=["alicloud_ram_role_policy_attachment.foo"]))
        ```

        EventBridge trigger:

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        config = pulumi.Config()
        name = config.get("name")
        if name is None:
            name = "fctriggereventbridgeconfig"
        current = alicloud.get_account()
        # Please make eventbridge available and then assume a specific service-linked role, which refers to https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/event_bridge_service_linked_role
        service_linked_role = alicloud.eventbridge.ServiceLinkedRole("serviceLinkedRole", product_name="AliyunServiceRoleForEventBridgeSendToFC")
        foo_service = alicloud.fc.Service("fooService", internet_access=False)
        foo_bucket = alicloud.oss.Bucket("fooBucket", bucket=name)
        # If you upload the function by OSS Bucket, you need to specify path can't upload by content.
        foo_bucket_object = alicloud.oss.BucketObject("fooBucketObject",
            bucket=foo_bucket.id,
            key="fc/hello.zip",
            source="./hello.zip")
        foo_function = alicloud.fc.Function("fooFunction",
            handler="hello.handler",
            memory_size=512,
            oss_bucket=foo_bucket.id,
            oss_key=foo_bucket_object.key,
            runtime="python2.7",
            service=foo_service.name)
        default = alicloud.fc.Trigger("default",
            config=\"\"\"    {
                "triggerEnable": false,
                "asyncInvocationType": false,
                "eventRuleFilterPattern": "{\\"source\\":[\\"acs.oss\\"],\\"type\\":[\\"oss:BucketCreated:PutBucket\\"]}",
                "eventSourceConfig": {
                    "eventSourceType": "Default"
                }
            }

        \"\"\",
            function=foo_function.name,
            service=foo_service.name,
            type="eventbridge")
        mns = alicloud.fc.Trigger("mns",
            config=\"\"\"    {
                "triggerEnable": false,
                "asyncInvocationType": false,
                "eventRuleFilterPattern": "{}",
                "eventSourceConfig": {
                    "eventSourceType": "MNS",
                    "eventSourceParameters": {
                        "sourceMNSParameters": {
                            "RegionId": "cn-hangzhou",
                            "QueueName": "mns-queue",
                            "IsBase64Decode": true
                        }
                    }
                }
            }

        \"\"\",
            function=foo_function.name,
            service=foo_service.name,
            type="eventbridge")
        rocketmq = alicloud.fc.Trigger("rocketmq",
            config=\"\"\"    {
                "triggerEnable": false,
                "asyncInvocationType": false,
                "eventRuleFilterPattern": "{}",
                "eventSourceConfig": {
                    "eventSourceType": "RocketMQ",
                    "eventSourceParameters": {
                        "sourceRocketMQParameters": {
                            "RegionId": "cn-hangzhou",
                            "InstanceId": "MQ_INST_164901546557****_BAAN****",
                            "GroupID": "GID_group1",
                            "Topic": "mytopic",
                            "Timestamp": 1636597951984,
                            "Tag": "test-tag",
                            "Offset": "CONSUME_FROM_LAST_OFFSET"
                        }
                    }
                }
            }

        \"\"\",
            function=foo_function.name,
            service=foo_service.name,
            type="eventbridge")
        rabbitmq = alicloud.fc.Trigger("rabbitmq",
            config=\"\"\"    {
                "triggerEnable": false,
                "asyncInvocationType": false,
                "eventRuleFilterPattern": "{}",
                "eventSourceConfig": {
                    "eventSourceType": "RabbitMQ",
                    "eventSourceParameters": {
                        "sourceRabbitMQParameters": {
                            "RegionId": "cn-hangzhou",
                            "InstanceId": "amqp-cn-****** ",
                            "VirtualHostName": "test-virtual",
                            "QueueName": "test-queue"
                        }
                    }
                }
            }

        \"\"\",
            function=foo_function.name,
            service=foo_service.name,
            type="eventbridge")
        ```
        ## Module Support

        You can use to the existing fc module
        to create several triggers quickly.

        ## Import

        Function Compute trigger can be imported using the id, e.g.

        ```sh
         $ pulumi import alicloud:fc/trigger:Trigger foo my-fc-service:hello-world:hello-trigger
        ```

        :param str resource_name: The name of the resource.
        :param TriggerArgs args: The arguments to use to populate this resource's properties.
        :param pulumi.ResourceOptions opts: Options for the resource.
        """
        ...
    def __init__(__self__, resource_name: str, *args, **kwargs):
        resource_args, opts = _utilities.get_resource_args_opts(TriggerArgs, pulumi.ResourceOptions, *args, **kwargs)
        if resource_args is not None:
            __self__._internal_init(resource_name, opts, **resource_args.__dict__)
        else:
            __self__._internal_init(resource_name, *args, **kwargs)

    def _internal_init(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 config: Optional[pulumi.Input[str]] = None,
                 config_mns: Optional[pulumi.Input[str]] = None,
                 function: Optional[pulumi.Input[str]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 name_prefix: Optional[pulumi.Input[str]] = None,
                 role: Optional[pulumi.Input[str]] = None,
                 service: Optional[pulumi.Input[str]] = None,
                 source_arn: Optional[pulumi.Input[str]] = None,
                 type: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        if opts.id is None:
            if __props__ is not None:
                raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
            __props__ = TriggerArgs.__new__(TriggerArgs)

            __props__.__dict__["config"] = config
            __props__.__dict__["config_mns"] = config_mns
            if function is None and not opts.urn:
                raise TypeError("Missing required property 'function'")
            __props__.__dict__["function"] = function
            __props__.__dict__["name"] = name
            __props__.__dict__["name_prefix"] = name_prefix
            __props__.__dict__["role"] = role
            if service is None and not opts.urn:
                raise TypeError("Missing required property 'service'")
            __props__.__dict__["service"] = service
            __props__.__dict__["source_arn"] = source_arn
            if type is None and not opts.urn:
                raise TypeError("Missing required property 'type'")
            __props__.__dict__["type"] = type
            __props__.__dict__["last_modified"] = None
            __props__.__dict__["trigger_id"] = None
        super(Trigger, __self__).__init__(
            'alicloud:fc/trigger:Trigger',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            config: Optional[pulumi.Input[str]] = None,
            config_mns: Optional[pulumi.Input[str]] = None,
            function: Optional[pulumi.Input[str]] = None,
            last_modified: Optional[pulumi.Input[str]] = None,
            name: Optional[pulumi.Input[str]] = None,
            name_prefix: Optional[pulumi.Input[str]] = None,
            role: Optional[pulumi.Input[str]] = None,
            service: Optional[pulumi.Input[str]] = None,
            source_arn: Optional[pulumi.Input[str]] = None,
            trigger_id: Optional[pulumi.Input[str]] = None,
            type: Optional[pulumi.Input[str]] = None) -> 'Trigger':
        """
        Get an existing Trigger resource's state with the given name, id, and optional extra
        properties used to qualify the lookup.

        :param str resource_name: The unique name of the resulting resource.
        :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] config: The config of Function Compute trigger.It is valid when `type` is not "mns_topic".See [Configure triggers and events](https://www.alibabacloud.com/help/doc-detail/70140.htm) for more details.
        :param pulumi.Input[str] config_mns: The config of Function Compute trigger when the type is "mns_topic".It is conflict with `config`.
        :param pulumi.Input[str] function: The Function Compute function name.
        :param pulumi.Input[str] last_modified: The date this resource was last modified.
        :param pulumi.Input[str] name: The Function Compute trigger name. It is the only in one service and is conflict with "name_prefix".
        :param pulumi.Input[str] name_prefix: Setting a prefix to get a only trigger name. It is conflict with "name".
        :param pulumi.Input[str] role: RAM role arn attached to the Function Compute trigger. Role used by the event source to call the function. The value format is "acs:ram::$account-id:role/$role-name". See [Create a trigger](https://www.alibabacloud.com/help/doc-detail/53102.htm) for more details.
        :param pulumi.Input[str] service: The Function Compute service name.
        :param pulumi.Input[str] source_arn: Event source resource address. See [Create a trigger](https://www.alibabacloud.com/help/doc-detail/53102.htm) for more details.
        :param pulumi.Input[str] trigger_id: The Function Compute trigger ID.
        :param pulumi.Input[str] type: The Type of the trigger. Valid values: ["oss", "log", "timer", "http", "mns_topic", "cdn_events", "eventbridge"].
               
               > **NOTE:** Config does not support modification when type is mns_topic.
               > **NOTE:** type = cdn_events, available in 1.47.0+.
               > **NOTE:** type = eventbridge, available in 1.173.0+.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _TriggerState.__new__(_TriggerState)

        __props__.__dict__["config"] = config
        __props__.__dict__["config_mns"] = config_mns
        __props__.__dict__["function"] = function
        __props__.__dict__["last_modified"] = last_modified
        __props__.__dict__["name"] = name
        __props__.__dict__["name_prefix"] = name_prefix
        __props__.__dict__["role"] = role
        __props__.__dict__["service"] = service
        __props__.__dict__["source_arn"] = source_arn
        __props__.__dict__["trigger_id"] = trigger_id
        __props__.__dict__["type"] = type
        return Trigger(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter
    def config(self) -> pulumi.Output[Optional[str]]:
        """
        The config of Function Compute trigger.It is valid when `type` is not "mns_topic".See [Configure triggers and events](https://www.alibabacloud.com/help/doc-detail/70140.htm) for more details.
        """
        return pulumi.get(self, "config")

    @property
    @pulumi.getter(name="configMns")
    def config_mns(self) -> pulumi.Output[Optional[str]]:
        """
        The config of Function Compute trigger when the type is "mns_topic".It is conflict with `config`.
        """
        return pulumi.get(self, "config_mns")

    @property
    @pulumi.getter
    def function(self) -> pulumi.Output[str]:
        """
        The Function Compute function name.
        """
        return pulumi.get(self, "function")

    @property
    @pulumi.getter(name="lastModified")
    def last_modified(self) -> pulumi.Output[str]:
        """
        The date this resource was last modified.
        """
        return pulumi.get(self, "last_modified")

    @property
    @pulumi.getter
    def name(self) -> pulumi.Output[str]:
        """
        The Function Compute trigger name. It is the only in one service and is conflict with "name_prefix".
        """
        return pulumi.get(self, "name")

    @property
    @pulumi.getter(name="namePrefix")
    def name_prefix(self) -> pulumi.Output[Optional[str]]:
        """
        Setting a prefix to get a only trigger name. It is conflict with "name".
        """
        return pulumi.get(self, "name_prefix")

    @property
    @pulumi.getter
    def role(self) -> pulumi.Output[Optional[str]]:
        """
        RAM role arn attached to the Function Compute trigger. Role used by the event source to call the function. The value format is "acs:ram::$account-id:role/$role-name". See [Create a trigger](https://www.alibabacloud.com/help/doc-detail/53102.htm) for more details.
        """
        return pulumi.get(self, "role")

    @property
    @pulumi.getter
    def service(self) -> pulumi.Output[str]:
        """
        The Function Compute service name.
        """
        return pulumi.get(self, "service")

    @property
    @pulumi.getter(name="sourceArn")
    def source_arn(self) -> pulumi.Output[Optional[str]]:
        """
        Event source resource address. See [Create a trigger](https://www.alibabacloud.com/help/doc-detail/53102.htm) for more details.
        """
        return pulumi.get(self, "source_arn")

    @property
    @pulumi.getter(name="triggerId")
    def trigger_id(self) -> pulumi.Output[str]:
        """
        The Function Compute trigger ID.
        """
        return pulumi.get(self, "trigger_id")

    @property
    @pulumi.getter
    def type(self) -> pulumi.Output[str]:
        """
        The Type of the trigger. Valid values: ["oss", "log", "timer", "http", "mns_topic", "cdn_events", "eventbridge"].

        > **NOTE:** Config does not support modification when type is mns_topic.
        > **NOTE:** type = cdn_events, available in 1.47.0+.
        > **NOTE:** type = eventbridge, available in 1.173.0+.
        """
        return pulumi.get(self, "type")

