1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. fc
  5. FunctionAsyncInvokeConfig
Alibaba Cloud v3.44.0 published on Thursday, Sep 28, 2023 by Pulumi

alicloud.fc.FunctionAsyncInvokeConfig

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.44.0 published on Thursday, Sep 28, 2023 by Pulumi

    Manages an asynchronous invocation configuration for a FC Function or Alias.
    For the detailed information, please refer to the developer guide.

    NOTE: Available since v1.100.0.

    Example Usage

    Destination Configuration

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    using Random = Pulumi.Random;
    
    return await Deployment.RunAsync(() => 
    {
        var defaultAccount = AliCloud.GetAccount.Invoke();
    
        var defaultRegions = AliCloud.GetRegions.Invoke(new()
        {
            Current = true,
        });
    
        var defaultRandomInteger = new Random.RandomInteger("defaultRandomInteger", new()
        {
            Max = 99999,
            Min = 10000,
        });
    
        var defaultRole = new AliCloud.Ram.Role("defaultRole", new()
        {
            Document = @"	{
    		""Statement"": [
    		  {
    			""Action"": ""sts:AssumeRole"",
    			""Effect"": ""Allow"",
    			""Principal"": {
    			  ""Service"": [
    				""fc.aliyuncs.com""
    			  ]
    			}
    		  }
    		],
    		""Version"": ""1""
    	}
    ",
            Description = "this is a example",
            Force = true,
        });
    
        var defaultPolicy = new AliCloud.Ram.Policy("defaultPolicy", new()
        {
            PolicyName = defaultRandomInteger.Result.Apply(result => $"examplepolicy{result}"),
            PolicyDocument = @"	{
    		""Version"": ""1"",
    		""Statement"": [
    		  {
    			""Action"": ""mns:*"",
    			""Resource"": ""*"",
    			""Effect"": ""Allow""
    		  }
    		]
    	  }
    ",
        });
    
        var defaultRolePolicyAttachment = new AliCloud.Ram.RolePolicyAttachment("defaultRolePolicyAttachment", new()
        {
            RoleName = defaultRole.Name,
            PolicyName = defaultPolicy.Name,
            PolicyType = "Custom",
        });
    
        var defaultService = new AliCloud.FC.Service("defaultService", new()
        {
            Description = "example-value",
            Role = defaultRole.Arn,
            InternetAccess = false,
        });
    
        var defaultBucket = new AliCloud.Oss.Bucket("defaultBucket", new()
        {
            BucketName = defaultRandomInteger.Result.Apply(result => $"terraform-example-{result}"),
        });
    
        // If you upload the function by OSS Bucket, you need to specify path can't upload by content.
        var defaultBucketObject = new AliCloud.Oss.BucketObject("defaultBucketObject", new()
        {
            Bucket = defaultBucket.Id,
            Key = "index.py",
            Content = @"import logging 
    def handler(event, context): 
    logger = logging.getLogger() 
    logger.info('hello world') 
    return 'hello world'",
        });
    
        var defaultFunction = new AliCloud.FC.Function("defaultFunction", new()
        {
            Service = defaultService.Name,
            Description = "example",
            OssBucket = defaultBucket.Id,
            OssKey = defaultBucketObject.Key,
            MemorySize = 512,
            Runtime = "python3.10",
            Handler = "hello.handler",
        });
    
        var defaultQueue = new AliCloud.Mns.Queue("defaultQueue");
    
        var defaultTopic = new AliCloud.Mns.Topic("defaultTopic");
    
        var defaultFunctionAsyncInvokeConfig = new AliCloud.FC.FunctionAsyncInvokeConfig("defaultFunctionAsyncInvokeConfig", new()
        {
            ServiceName = defaultService.Name,
            FunctionName = defaultFunction.Name,
            DestinationConfig = new AliCloud.FC.Inputs.FunctionAsyncInvokeConfigDestinationConfigArgs
            {
                OnFailure = new AliCloud.FC.Inputs.FunctionAsyncInvokeConfigDestinationConfigOnFailureArgs
                {
                    Destination = Output.Tuple(defaultRegions, defaultAccount, defaultQueue.Name).Apply(values =>
                    {
                        var defaultRegions = values.Item1;
                        var defaultAccount = values.Item2;
                        var name = values.Item3;
                        return $"acs:mns:{defaultRegions.Apply(getRegionsResult => getRegionsResult.Regions[0]?.Id)}:{defaultAccount.Apply(getAccountResult => getAccountResult.Id)}:/queues/{name}/messages";
                    }),
                },
                OnSuccess = new AliCloud.FC.Inputs.FunctionAsyncInvokeConfigDestinationConfigOnSuccessArgs
                {
                    Destination = Output.Tuple(defaultRegions, defaultAccount, defaultTopic.Name).Apply(values =>
                    {
                        var defaultRegions = values.Item1;
                        var defaultAccount = values.Item2;
                        var name = values.Item3;
                        return $"acs:mns:{defaultRegions.Apply(getRegionsResult => getRegionsResult.Regions[0]?.Id)}:{defaultAccount.Apply(getAccountResult => getAccountResult.Id)}:/topics/{name}/messages";
                    }),
                },
            },
            MaximumEventAgeInSeconds = 60,
            MaximumRetryAttempts = 0,
            StatefulInvocation = true,
            Qualifier = "LATEST",
        });
    
    });
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/fc"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/mns"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/oss"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ram"
    	"github.com/pulumi/pulumi-random/sdk/v4/go/random"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		defaultAccount, err := alicloud.GetAccount(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		defaultRegions, err := alicloud.GetRegions(ctx, &alicloud.GetRegionsArgs{
    			Current: pulumi.BoolRef(true),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultRandomInteger, err := random.NewRandomInteger(ctx, "defaultRandomInteger", &random.RandomIntegerArgs{
    			Max: pulumi.Int(99999),
    			Min: pulumi.Int(10000),
    		})
    		if err != nil {
    			return err
    		}
    		defaultRole, err := ram.NewRole(ctx, "defaultRole", &ram.RoleArgs{
    			Document: pulumi.String(`	{
    		"Statement": [
    		  {
    			"Action": "sts:AssumeRole",
    			"Effect": "Allow",
    			"Principal": {
    			  "Service": [
    				"fc.aliyuncs.com"
    			  ]
    			}
    		  }
    		],
    		"Version": "1"
    	}
    `),
    			Description: pulumi.String("this is a example"),
    			Force:       pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		defaultPolicy, err := ram.NewPolicy(ctx, "defaultPolicy", &ram.PolicyArgs{
    			PolicyName: defaultRandomInteger.Result.ApplyT(func(result int) (string, error) {
    				return fmt.Sprintf("examplepolicy%v", result), nil
    			}).(pulumi.StringOutput),
    			PolicyDocument: pulumi.String(`	{
    		"Version": "1",
    		"Statement": [
    		  {
    			"Action": "mns:*",
    			"Resource": "*",
    			"Effect": "Allow"
    		  }
    		]
    	  }
    `),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = ram.NewRolePolicyAttachment(ctx, "defaultRolePolicyAttachment", &ram.RolePolicyAttachmentArgs{
    			RoleName:   defaultRole.Name,
    			PolicyName: defaultPolicy.Name,
    			PolicyType: pulumi.String("Custom"),
    		})
    		if err != nil {
    			return err
    		}
    		defaultService, err := fc.NewService(ctx, "defaultService", &fc.ServiceArgs{
    			Description:    pulumi.String("example-value"),
    			Role:           defaultRole.Arn,
    			InternetAccess: pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		defaultBucket, err := oss.NewBucket(ctx, "defaultBucket", &oss.BucketArgs{
    			Bucket: defaultRandomInteger.Result.ApplyT(func(result int) (string, error) {
    				return fmt.Sprintf("terraform-example-%v", result), nil
    			}).(pulumi.StringOutput),
    		})
    		if err != nil {
    			return err
    		}
    		defaultBucketObject, err := oss.NewBucketObject(ctx, "defaultBucketObject", &oss.BucketObjectArgs{
    			Bucket:  defaultBucket.ID(),
    			Key:     pulumi.String("index.py"),
    			Content: pulumi.String("import logging \ndef handler(event, context): \nlogger = logging.getLogger() \nlogger.info('hello world') \nreturn 'hello world'"),
    		})
    		if err != nil {
    			return err
    		}
    		defaultFunction, err := fc.NewFunction(ctx, "defaultFunction", &fc.FunctionArgs{
    			Service:     defaultService.Name,
    			Description: pulumi.String("example"),
    			OssBucket:   defaultBucket.ID(),
    			OssKey:      defaultBucketObject.Key,
    			MemorySize:  pulumi.Int(512),
    			Runtime:     pulumi.String("python3.10"),
    			Handler:     pulumi.String("hello.handler"),
    		})
    		if err != nil {
    			return err
    		}
    		defaultQueue, err := mns.NewQueue(ctx, "defaultQueue", nil)
    		if err != nil {
    			return err
    		}
    		defaultTopic, err := mns.NewTopic(ctx, "defaultTopic", nil)
    		if err != nil {
    			return err
    		}
    		_, err = fc.NewFunctionAsyncInvokeConfig(ctx, "defaultFunctionAsyncInvokeConfig", &fc.FunctionAsyncInvokeConfigArgs{
    			ServiceName:  defaultService.Name,
    			FunctionName: defaultFunction.Name,
    			DestinationConfig: &fc.FunctionAsyncInvokeConfigDestinationConfigArgs{
    				OnFailure: &fc.FunctionAsyncInvokeConfigDestinationConfigOnFailureArgs{
    					Destination: defaultQueue.Name.ApplyT(func(name string) (string, error) {
    						return fmt.Sprintf("acs:mns:%v:%v:/queues/%v/messages", defaultRegions.Regions[0].Id, defaultAccount.Id, name), nil
    					}).(pulumi.StringOutput),
    				},
    				OnSuccess: &fc.FunctionAsyncInvokeConfigDestinationConfigOnSuccessArgs{
    					Destination: defaultTopic.Name.ApplyT(func(name string) (string, error) {
    						return fmt.Sprintf("acs:mns:%v:%v:/topics/%v/messages", defaultRegions.Regions[0].Id, defaultAccount.Id, name), nil
    					}).(pulumi.StringOutput),
    				},
    			},
    			MaximumEventAgeInSeconds: pulumi.Int(60),
    			MaximumRetryAttempts:     pulumi.Int(0),
    			StatefulInvocation:       pulumi.Bool(true),
    			Qualifier:                pulumi.String("LATEST"),
    		})
    		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.AlicloudFunctions;
    import com.pulumi.alicloud.inputs.GetRegionsArgs;
    import com.pulumi.random.RandomInteger;
    import com.pulumi.random.RandomIntegerArgs;
    import com.pulumi.alicloud.ram.Role;
    import com.pulumi.alicloud.ram.RoleArgs;
    import com.pulumi.alicloud.ram.Policy;
    import com.pulumi.alicloud.ram.PolicyArgs;
    import com.pulumi.alicloud.ram.RolePolicyAttachment;
    import com.pulumi.alicloud.ram.RolePolicyAttachmentArgs;
    import com.pulumi.alicloud.fc.Service;
    import com.pulumi.alicloud.fc.ServiceArgs;
    import com.pulumi.alicloud.oss.Bucket;
    import com.pulumi.alicloud.oss.BucketArgs;
    import com.pulumi.alicloud.oss.BucketObject;
    import com.pulumi.alicloud.oss.BucketObjectArgs;
    import com.pulumi.alicloud.fc.Function;
    import com.pulumi.alicloud.fc.FunctionArgs;
    import com.pulumi.alicloud.mns.Queue;
    import com.pulumi.alicloud.mns.Topic;
    import com.pulumi.alicloud.fc.FunctionAsyncInvokeConfig;
    import com.pulumi.alicloud.fc.FunctionAsyncInvokeConfigArgs;
    import com.pulumi.alicloud.fc.inputs.FunctionAsyncInvokeConfigDestinationConfigArgs;
    import com.pulumi.alicloud.fc.inputs.FunctionAsyncInvokeConfigDestinationConfigOnFailureArgs;
    import com.pulumi.alicloud.fc.inputs.FunctionAsyncInvokeConfigDestinationConfigOnSuccessArgs;
    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 defaultAccount = AlicloudFunctions.getAccount();
    
            final var defaultRegions = AlicloudFunctions.getRegions(GetRegionsArgs.builder()
                .current(true)
                .build());
    
            var defaultRandomInteger = new RandomInteger("defaultRandomInteger", RandomIntegerArgs.builder()        
                .max(99999)
                .min(10000)
                .build());
    
            var defaultRole = new Role("defaultRole", RoleArgs.builder()        
                .document("""
    	{
    		"Statement": [
    		  {
    			"Action": "sts:AssumeRole",
    			"Effect": "Allow",
    			"Principal": {
    			  "Service": [
    				"fc.aliyuncs.com"
    			  ]
    			}
    		  }
    		],
    		"Version": "1"
    	}
                """)
                .description("this is a example")
                .force(true)
                .build());
    
            var defaultPolicy = new Policy("defaultPolicy", PolicyArgs.builder()        
                .policyName(defaultRandomInteger.result().applyValue(result -> String.format("examplepolicy%s", result)))
                .policyDocument("""
    	{
    		"Version": "1",
    		"Statement": [
    		  {
    			"Action": "mns:*",
    			"Resource": "*",
    			"Effect": "Allow"
    		  }
    		]
    	  }
                """)
                .build());
    
            var defaultRolePolicyAttachment = new RolePolicyAttachment("defaultRolePolicyAttachment", RolePolicyAttachmentArgs.builder()        
                .roleName(defaultRole.name())
                .policyName(defaultPolicy.name())
                .policyType("Custom")
                .build());
    
            var defaultService = new Service("defaultService", ServiceArgs.builder()        
                .description("example-value")
                .role(defaultRole.arn())
                .internetAccess(false)
                .build());
    
            var defaultBucket = new Bucket("defaultBucket", BucketArgs.builder()        
                .bucket(defaultRandomInteger.result().applyValue(result -> String.format("terraform-example-%s", result)))
                .build());
    
            var defaultBucketObject = new BucketObject("defaultBucketObject", BucketObjectArgs.builder()        
                .bucket(defaultBucket.id())
                .key("index.py")
                .content("""
    import logging 
    def handler(event, context): 
    logger = logging.getLogger() 
    logger.info('hello world') 
    return 'hello world'            """)
                .build());
    
            var defaultFunction = new Function("defaultFunction", FunctionArgs.builder()        
                .service(defaultService.name())
                .description("example")
                .ossBucket(defaultBucket.id())
                .ossKey(defaultBucketObject.key())
                .memorySize("512")
                .runtime("python3.10")
                .handler("hello.handler")
                .build());
    
            var defaultQueue = new Queue("defaultQueue");
    
            var defaultTopic = new Topic("defaultTopic");
    
            var defaultFunctionAsyncInvokeConfig = new FunctionAsyncInvokeConfig("defaultFunctionAsyncInvokeConfig", FunctionAsyncInvokeConfigArgs.builder()        
                .serviceName(defaultService.name())
                .functionName(defaultFunction.name())
                .destinationConfig(FunctionAsyncInvokeConfigDestinationConfigArgs.builder()
                    .onFailure(FunctionAsyncInvokeConfigDestinationConfigOnFailureArgs.builder()
                        .destination(defaultQueue.name().applyValue(name -> String.format("acs:mns:%s:%s:/queues/%s/messages", defaultRegions.applyValue(getRegionsResult -> getRegionsResult.regions()[0].id()),defaultAccount.applyValue(getAccountResult -> getAccountResult.id()),name)))
                        .build())
                    .onSuccess(FunctionAsyncInvokeConfigDestinationConfigOnSuccessArgs.builder()
                        .destination(defaultTopic.name().applyValue(name -> String.format("acs:mns:%s:%s:/topics/%s/messages", defaultRegions.applyValue(getRegionsResult -> getRegionsResult.regions()[0].id()),defaultAccount.applyValue(getAccountResult -> getAccountResult.id()),name)))
                        .build())
                    .build())
                .maximumEventAgeInSeconds(60)
                .maximumRetryAttempts(0)
                .statefulInvocation(true)
                .qualifier("LATEST")
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_alicloud as alicloud
    import pulumi_random as random
    
    default_account = alicloud.get_account()
    default_regions = alicloud.get_regions(current=True)
    default_random_integer = random.RandomInteger("defaultRandomInteger",
        max=99999,
        min=10000)
    default_role = alicloud.ram.Role("defaultRole",
        document="""	{
    		"Statement": [
    		  {
    			"Action": "sts:AssumeRole",
    			"Effect": "Allow",
    			"Principal": {
    			  "Service": [
    				"fc.aliyuncs.com"
    			  ]
    			}
    		  }
    		],
    		"Version": "1"
    	}
    """,
        description="this is a example",
        force=True)
    default_policy = alicloud.ram.Policy("defaultPolicy",
        policy_name=default_random_integer.result.apply(lambda result: f"examplepolicy{result}"),
        policy_document="""	{
    		"Version": "1",
    		"Statement": [
    		  {
    			"Action": "mns:*",
    			"Resource": "*",
    			"Effect": "Allow"
    		  }
    		]
    	  }
    """)
    default_role_policy_attachment = alicloud.ram.RolePolicyAttachment("defaultRolePolicyAttachment",
        role_name=default_role.name,
        policy_name=default_policy.name,
        policy_type="Custom")
    default_service = alicloud.fc.Service("defaultService",
        description="example-value",
        role=default_role.arn,
        internet_access=False)
    default_bucket = alicloud.oss.Bucket("defaultBucket", bucket=default_random_integer.result.apply(lambda result: f"terraform-example-{result}"))
    # If you upload the function by OSS Bucket, you need to specify path can't upload by content.
    default_bucket_object = alicloud.oss.BucketObject("defaultBucketObject",
        bucket=default_bucket.id,
        key="index.py",
        content="""import logging 
    def handler(event, context): 
    logger = logging.getLogger() 
    logger.info('hello world') 
    return 'hello world'""")
    default_function = alicloud.fc.Function("defaultFunction",
        service=default_service.name,
        description="example",
        oss_bucket=default_bucket.id,
        oss_key=default_bucket_object.key,
        memory_size=512,
        runtime="python3.10",
        handler="hello.handler")
    default_queue = alicloud.mns.Queue("defaultQueue")
    default_topic = alicloud.mns.Topic("defaultTopic")
    default_function_async_invoke_config = alicloud.fc.FunctionAsyncInvokeConfig("defaultFunctionAsyncInvokeConfig",
        service_name=default_service.name,
        function_name=default_function.name,
        destination_config=alicloud.fc.FunctionAsyncInvokeConfigDestinationConfigArgs(
            on_failure=alicloud.fc.FunctionAsyncInvokeConfigDestinationConfigOnFailureArgs(
                destination=default_queue.name.apply(lambda name: f"acs:mns:{default_regions.regions[0].id}:{default_account.id}:/queues/{name}/messages"),
            ),
            on_success=alicloud.fc.FunctionAsyncInvokeConfigDestinationConfigOnSuccessArgs(
                destination=default_topic.name.apply(lambda name: f"acs:mns:{default_regions.regions[0].id}:{default_account.id}:/topics/{name}/messages"),
            ),
        ),
        maximum_event_age_in_seconds=60,
        maximum_retry_attempts=0,
        stateful_invocation=True,
        qualifier="LATEST")
    
    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    import * as random from "@pulumi/random";
    
    const defaultAccount = alicloud.getAccount({});
    const defaultRegions = alicloud.getRegions({
        current: true,
    });
    const defaultRandomInteger = new random.RandomInteger("defaultRandomInteger", {
        max: 99999,
        min: 10000,
    });
    const defaultRole = new alicloud.ram.Role("defaultRole", {
        document: `	{
    		"Statement": [
    		  {
    			"Action": "sts:AssumeRole",
    			"Effect": "Allow",
    			"Principal": {
    			  "Service": [
    				"fc.aliyuncs.com"
    			  ]
    			}
    		  }
    		],
    		"Version": "1"
    	}
    `,
        description: "this is a example",
        force: true,
    });
    const defaultPolicy = new alicloud.ram.Policy("defaultPolicy", {
        policyName: pulumi.interpolate`examplepolicy${defaultRandomInteger.result}`,
        policyDocument: `	{
    		"Version": "1",
    		"Statement": [
    		  {
    			"Action": "mns:*",
    			"Resource": "*",
    			"Effect": "Allow"
    		  }
    		]
    	  }
    `,
    });
    const defaultRolePolicyAttachment = new alicloud.ram.RolePolicyAttachment("defaultRolePolicyAttachment", {
        roleName: defaultRole.name,
        policyName: defaultPolicy.name,
        policyType: "Custom",
    });
    const defaultService = new alicloud.fc.Service("defaultService", {
        description: "example-value",
        role: defaultRole.arn,
        internetAccess: false,
    });
    const defaultBucket = new alicloud.oss.Bucket("defaultBucket", {bucket: pulumi.interpolate`terraform-example-${defaultRandomInteger.result}`});
    // If you upload the function by OSS Bucket, you need to specify path can't upload by content.
    const defaultBucketObject = new alicloud.oss.BucketObject("defaultBucketObject", {
        bucket: defaultBucket.id,
        key: "index.py",
        content: `import logging 
    def handler(event, context): 
    logger = logging.getLogger() 
    logger.info('hello world') 
    return 'hello world'`,
    });
    const defaultFunction = new alicloud.fc.Function("defaultFunction", {
        service: defaultService.name,
        description: "example",
        ossBucket: defaultBucket.id,
        ossKey: defaultBucketObject.key,
        memorySize: 512,
        runtime: "python3.10",
        handler: "hello.handler",
    });
    const defaultQueue = new alicloud.mns.Queue("defaultQueue", {});
    const defaultTopic = new alicloud.mns.Topic("defaultTopic", {});
    const defaultFunctionAsyncInvokeConfig = new alicloud.fc.FunctionAsyncInvokeConfig("defaultFunctionAsyncInvokeConfig", {
        serviceName: defaultService.name,
        functionName: defaultFunction.name,
        destinationConfig: {
            onFailure: {
                destination: pulumi.all([defaultRegions, defaultAccount, defaultQueue.name]).apply(([defaultRegions, defaultAccount, name]) => `acs:mns:${defaultRegions.regions?.[0]?.id}:${defaultAccount.id}:/queues/${name}/messages`),
            },
            onSuccess: {
                destination: pulumi.all([defaultRegions, defaultAccount, defaultTopic.name]).apply(([defaultRegions, defaultAccount, name]) => `acs:mns:${defaultRegions.regions?.[0]?.id}:${defaultAccount.id}:/topics/${name}/messages`),
            },
        },
        maximumEventAgeInSeconds: 60,
        maximumRetryAttempts: 0,
        statefulInvocation: true,
        qualifier: "LATEST",
    });
    
    resources:
      defaultRandomInteger:
        type: random:RandomInteger
        properties:
          max: 99999
          min: 10000
      defaultRole:
        type: alicloud:ram:Role
        properties:
          document: |
            	{
            		"Statement": [
            		  {
            			"Action": "sts:AssumeRole",
            			"Effect": "Allow",
            			"Principal": {
            			  "Service": [
            				"fc.aliyuncs.com"
            			  ]
            			}
            		  }
            		],
            		"Version": "1"
            	}        
          description: this is a example
          force: true
      defaultPolicy:
        type: alicloud:ram:Policy
        properties:
          policyName: examplepolicy${defaultRandomInteger.result}
          policyDocument: |
            	{
            		"Version": "1",
            		"Statement": [
            		  {
            			"Action": "mns:*",
            			"Resource": "*",
            			"Effect": "Allow"
            		  }
            		]
            	  }        
      defaultRolePolicyAttachment:
        type: alicloud:ram:RolePolicyAttachment
        properties:
          roleName: ${defaultRole.name}
          policyName: ${defaultPolicy.name}
          policyType: Custom
      defaultService:
        type: alicloud:fc:Service
        properties:
          description: example-value
          role: ${defaultRole.arn}
          internetAccess: false
      defaultBucket:
        type: alicloud:oss:Bucket
        properties:
          bucket: terraform-example-${defaultRandomInteger.result}
      # If you upload the function by OSS Bucket, you need to specify path can't upload by content.
      defaultBucketObject:
        type: alicloud:oss:BucketObject
        properties:
          bucket: ${defaultBucket.id}
          key: index.py
          content: "import logging \ndef handler(event, context): \nlogger = logging.getLogger() \nlogger.info('hello world') \nreturn 'hello world'"
      defaultFunction:
        type: alicloud:fc:Function
        properties:
          service: ${defaultService.name}
          description: example
          ossBucket: ${defaultBucket.id}
          ossKey: ${defaultBucketObject.key}
          memorySize: '512'
          runtime: python3.10
          handler: hello.handler
      defaultQueue:
        type: alicloud:mns:Queue
      defaultTopic:
        type: alicloud:mns:Topic
      defaultFunctionAsyncInvokeConfig:
        type: alicloud:fc:FunctionAsyncInvokeConfig
        properties:
          serviceName: ${defaultService.name}
          functionName: ${defaultFunction.name}
          destinationConfig:
            onFailure:
              destination: acs:mns:${defaultRegions.regions[0].id}:${defaultAccount.id}:/queues/${defaultQueue.name}/messages
            onSuccess:
              destination: acs:mns:${defaultRegions.regions[0].id}:${defaultAccount.id}:/topics/${defaultTopic.name}/messages
          # Error Handling Configuration
          maximumEventAgeInSeconds: 60
          maximumRetryAttempts: 0
          # Async Job Configuration
          statefulInvocation: true
          # Configuration for Function Latest Unpublished Version
          qualifier: LATEST
    variables:
      defaultAccount:
        fn::invoke:
          Function: alicloud:getAccount
          Arguments: {}
      defaultRegions:
        fn::invoke:
          Function: alicloud:getRegions
          Arguments:
            current: true
    

    Create FunctionAsyncInvokeConfig Resource

    new FunctionAsyncInvokeConfig(name: string, args: FunctionAsyncInvokeConfigArgs, opts?: CustomResourceOptions);
    @overload
    def FunctionAsyncInvokeConfig(resource_name: str,
                                  opts: Optional[ResourceOptions] = None,
                                  destination_config: Optional[FunctionAsyncInvokeConfigDestinationConfigArgs] = None,
                                  function_name: Optional[str] = None,
                                  maximum_event_age_in_seconds: Optional[int] = None,
                                  maximum_retry_attempts: Optional[int] = None,
                                  qualifier: Optional[str] = None,
                                  service_name: Optional[str] = None,
                                  stateful_invocation: Optional[bool] = None)
    @overload
    def FunctionAsyncInvokeConfig(resource_name: str,
                                  args: FunctionAsyncInvokeConfigArgs,
                                  opts: Optional[ResourceOptions] = None)
    func NewFunctionAsyncInvokeConfig(ctx *Context, name string, args FunctionAsyncInvokeConfigArgs, opts ...ResourceOption) (*FunctionAsyncInvokeConfig, error)
    public FunctionAsyncInvokeConfig(string name, FunctionAsyncInvokeConfigArgs args, CustomResourceOptions? opts = null)
    public FunctionAsyncInvokeConfig(String name, FunctionAsyncInvokeConfigArgs args)
    public FunctionAsyncInvokeConfig(String name, FunctionAsyncInvokeConfigArgs args, CustomResourceOptions options)
    
    type: alicloud:fc:FunctionAsyncInvokeConfig
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args FunctionAsyncInvokeConfigArgs
    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 FunctionAsyncInvokeConfigArgs
    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 FunctionAsyncInvokeConfigArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args FunctionAsyncInvokeConfigArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args FunctionAsyncInvokeConfigArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

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

    FunctionName string

    Name of the Function Compute Function.

    ServiceName string

    Name of the Function Compute Function, omitting any version or alias qualifier.

    DestinationConfig Pulumi.AliCloud.FC.Inputs.FunctionAsyncInvokeConfigDestinationConfig

    Configuration block with destination configuration. See destination_config below.

    MaximumEventAgeInSeconds int

    Maximum age of a request that Function Compute sends to a function for processing in seconds. Valid values between 1 and 2592000 (between 60 and 21600 before v1.167.0).

    MaximumRetryAttempts int

    Maximum number of times to retry when the function returns an error. Valid values between 0 and 8 (between 0 and 2 before v1.167.0). Defaults to 2.

    Qualifier string

    Function Compute Function published version, LATEST, or Function Compute Alias name. The default value is LATEST.

    StatefulInvocation bool

    Function Compute async job configuration(also known as Task Mode). valid values true or false, default false

    FunctionName string

    Name of the Function Compute Function.

    ServiceName string

    Name of the Function Compute Function, omitting any version or alias qualifier.

    DestinationConfig FunctionAsyncInvokeConfigDestinationConfigArgs

    Configuration block with destination configuration. See destination_config below.

    MaximumEventAgeInSeconds int

    Maximum age of a request that Function Compute sends to a function for processing in seconds. Valid values between 1 and 2592000 (between 60 and 21600 before v1.167.0).

    MaximumRetryAttempts int

    Maximum number of times to retry when the function returns an error. Valid values between 0 and 8 (between 0 and 2 before v1.167.0). Defaults to 2.

    Qualifier string

    Function Compute Function published version, LATEST, or Function Compute Alias name. The default value is LATEST.

    StatefulInvocation bool

    Function Compute async job configuration(also known as Task Mode). valid values true or false, default false

    functionName String

    Name of the Function Compute Function.

    serviceName String

    Name of the Function Compute Function, omitting any version or alias qualifier.

    destinationConfig FunctionAsyncInvokeConfigDestinationConfig

    Configuration block with destination configuration. See destination_config below.

    maximumEventAgeInSeconds Integer

    Maximum age of a request that Function Compute sends to a function for processing in seconds. Valid values between 1 and 2592000 (between 60 and 21600 before v1.167.0).

    maximumRetryAttempts Integer

    Maximum number of times to retry when the function returns an error. Valid values between 0 and 8 (between 0 and 2 before v1.167.0). Defaults to 2.

    qualifier String

    Function Compute Function published version, LATEST, or Function Compute Alias name. The default value is LATEST.

    statefulInvocation Boolean

    Function Compute async job configuration(also known as Task Mode). valid values true or false, default false

    functionName string

    Name of the Function Compute Function.

    serviceName string

    Name of the Function Compute Function, omitting any version or alias qualifier.

    destinationConfig FunctionAsyncInvokeConfigDestinationConfig

    Configuration block with destination configuration. See destination_config below.

    maximumEventAgeInSeconds number

    Maximum age of a request that Function Compute sends to a function for processing in seconds. Valid values between 1 and 2592000 (between 60 and 21600 before v1.167.0).

    maximumRetryAttempts number

    Maximum number of times to retry when the function returns an error. Valid values between 0 and 8 (between 0 and 2 before v1.167.0). Defaults to 2.

    qualifier string

    Function Compute Function published version, LATEST, or Function Compute Alias name. The default value is LATEST.

    statefulInvocation boolean

    Function Compute async job configuration(also known as Task Mode). valid values true or false, default false

    function_name str

    Name of the Function Compute Function.

    service_name str

    Name of the Function Compute Function, omitting any version or alias qualifier.

    destination_config FunctionAsyncInvokeConfigDestinationConfigArgs

    Configuration block with destination configuration. See destination_config below.

    maximum_event_age_in_seconds int

    Maximum age of a request that Function Compute sends to a function for processing in seconds. Valid values between 1 and 2592000 (between 60 and 21600 before v1.167.0).

    maximum_retry_attempts int

    Maximum number of times to retry when the function returns an error. Valid values between 0 and 8 (between 0 and 2 before v1.167.0). Defaults to 2.

    qualifier str

    Function Compute Function published version, LATEST, or Function Compute Alias name. The default value is LATEST.

    stateful_invocation bool

    Function Compute async job configuration(also known as Task Mode). valid values true or false, default false

    functionName String

    Name of the Function Compute Function.

    serviceName String

    Name of the Function Compute Function, omitting any version or alias qualifier.

    destinationConfig Property Map

    Configuration block with destination configuration. See destination_config below.

    maximumEventAgeInSeconds Number

    Maximum age of a request that Function Compute sends to a function for processing in seconds. Valid values between 1 and 2592000 (between 60 and 21600 before v1.167.0).

    maximumRetryAttempts Number

    Maximum number of times to retry when the function returns an error. Valid values between 0 and 8 (between 0 and 2 before v1.167.0). Defaults to 2.

    qualifier String

    Function Compute Function published version, LATEST, or Function Compute Alias name. The default value is LATEST.

    statefulInvocation Boolean

    Function Compute async job configuration(also known as Task Mode). valid values true or false, default false

    Outputs

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

    CreatedTime string

    The date this resource was created.

    Id string

    The provider-assigned unique ID for this managed resource.

    LastModifiedTime string

    The date this resource was last modified.

    CreatedTime string

    The date this resource was created.

    Id string

    The provider-assigned unique ID for this managed resource.

    LastModifiedTime string

    The date this resource was last modified.

    createdTime String

    The date this resource was created.

    id String

    The provider-assigned unique ID for this managed resource.

    lastModifiedTime String

    The date this resource was last modified.

    createdTime string

    The date this resource was created.

    id string

    The provider-assigned unique ID for this managed resource.

    lastModifiedTime string

    The date this resource was last modified.

    created_time str

    The date this resource was created.

    id str

    The provider-assigned unique ID for this managed resource.

    last_modified_time str

    The date this resource was last modified.

    createdTime String

    The date this resource was created.

    id String

    The provider-assigned unique ID for this managed resource.

    lastModifiedTime String

    The date this resource was last modified.

    Look up Existing FunctionAsyncInvokeConfig Resource

    Get an existing FunctionAsyncInvokeConfig 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?: FunctionAsyncInvokeConfigState, opts?: CustomResourceOptions): FunctionAsyncInvokeConfig
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            created_time: Optional[str] = None,
            destination_config: Optional[FunctionAsyncInvokeConfigDestinationConfigArgs] = None,
            function_name: Optional[str] = None,
            last_modified_time: Optional[str] = None,
            maximum_event_age_in_seconds: Optional[int] = None,
            maximum_retry_attempts: Optional[int] = None,
            qualifier: Optional[str] = None,
            service_name: Optional[str] = None,
            stateful_invocation: Optional[bool] = None) -> FunctionAsyncInvokeConfig
    func GetFunctionAsyncInvokeConfig(ctx *Context, name string, id IDInput, state *FunctionAsyncInvokeConfigState, opts ...ResourceOption) (*FunctionAsyncInvokeConfig, error)
    public static FunctionAsyncInvokeConfig Get(string name, Input<string> id, FunctionAsyncInvokeConfigState? state, CustomResourceOptions? opts = null)
    public static FunctionAsyncInvokeConfig get(String name, Output<String> id, FunctionAsyncInvokeConfigState 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:
    CreatedTime string

    The date this resource was created.

    DestinationConfig Pulumi.AliCloud.FC.Inputs.FunctionAsyncInvokeConfigDestinationConfig

    Configuration block with destination configuration. See destination_config below.

    FunctionName string

    Name of the Function Compute Function.

    LastModifiedTime string

    The date this resource was last modified.

    MaximumEventAgeInSeconds int

    Maximum age of a request that Function Compute sends to a function for processing in seconds. Valid values between 1 and 2592000 (between 60 and 21600 before v1.167.0).

    MaximumRetryAttempts int

    Maximum number of times to retry when the function returns an error. Valid values between 0 and 8 (between 0 and 2 before v1.167.0). Defaults to 2.

    Qualifier string

    Function Compute Function published version, LATEST, or Function Compute Alias name. The default value is LATEST.

    ServiceName string

    Name of the Function Compute Function, omitting any version or alias qualifier.

    StatefulInvocation bool

    Function Compute async job configuration(also known as Task Mode). valid values true or false, default false

    CreatedTime string

    The date this resource was created.

    DestinationConfig FunctionAsyncInvokeConfigDestinationConfigArgs

    Configuration block with destination configuration. See destination_config below.

    FunctionName string

    Name of the Function Compute Function.

    LastModifiedTime string

    The date this resource was last modified.

    MaximumEventAgeInSeconds int

    Maximum age of a request that Function Compute sends to a function for processing in seconds. Valid values between 1 and 2592000 (between 60 and 21600 before v1.167.0).

    MaximumRetryAttempts int

    Maximum number of times to retry when the function returns an error. Valid values between 0 and 8 (between 0 and 2 before v1.167.0). Defaults to 2.

    Qualifier string

    Function Compute Function published version, LATEST, or Function Compute Alias name. The default value is LATEST.

    ServiceName string

    Name of the Function Compute Function, omitting any version or alias qualifier.

    StatefulInvocation bool

    Function Compute async job configuration(also known as Task Mode). valid values true or false, default false

    createdTime String

    The date this resource was created.

    destinationConfig FunctionAsyncInvokeConfigDestinationConfig

    Configuration block with destination configuration. See destination_config below.

    functionName String

    Name of the Function Compute Function.

    lastModifiedTime String

    The date this resource was last modified.

    maximumEventAgeInSeconds Integer

    Maximum age of a request that Function Compute sends to a function for processing in seconds. Valid values between 1 and 2592000 (between 60 and 21600 before v1.167.0).

    maximumRetryAttempts Integer

    Maximum number of times to retry when the function returns an error. Valid values between 0 and 8 (between 0 and 2 before v1.167.0). Defaults to 2.

    qualifier String

    Function Compute Function published version, LATEST, or Function Compute Alias name. The default value is LATEST.

    serviceName String

    Name of the Function Compute Function, omitting any version or alias qualifier.

    statefulInvocation Boolean

    Function Compute async job configuration(also known as Task Mode). valid values true or false, default false

    createdTime string

    The date this resource was created.

    destinationConfig FunctionAsyncInvokeConfigDestinationConfig

    Configuration block with destination configuration. See destination_config below.

    functionName string

    Name of the Function Compute Function.

    lastModifiedTime string

    The date this resource was last modified.

    maximumEventAgeInSeconds number

    Maximum age of a request that Function Compute sends to a function for processing in seconds. Valid values between 1 and 2592000 (between 60 and 21600 before v1.167.0).

    maximumRetryAttempts number

    Maximum number of times to retry when the function returns an error. Valid values between 0 and 8 (between 0 and 2 before v1.167.0). Defaults to 2.

    qualifier string

    Function Compute Function published version, LATEST, or Function Compute Alias name. The default value is LATEST.

    serviceName string

    Name of the Function Compute Function, omitting any version or alias qualifier.

    statefulInvocation boolean

    Function Compute async job configuration(also known as Task Mode). valid values true or false, default false

    created_time str

    The date this resource was created.

    destination_config FunctionAsyncInvokeConfigDestinationConfigArgs

    Configuration block with destination configuration. See destination_config below.

    function_name str

    Name of the Function Compute Function.

    last_modified_time str

    The date this resource was last modified.

    maximum_event_age_in_seconds int

    Maximum age of a request that Function Compute sends to a function for processing in seconds. Valid values between 1 and 2592000 (between 60 and 21600 before v1.167.0).

    maximum_retry_attempts int

    Maximum number of times to retry when the function returns an error. Valid values between 0 and 8 (between 0 and 2 before v1.167.0). Defaults to 2.

    qualifier str

    Function Compute Function published version, LATEST, or Function Compute Alias name. The default value is LATEST.

    service_name str

    Name of the Function Compute Function, omitting any version or alias qualifier.

    stateful_invocation bool

    Function Compute async job configuration(also known as Task Mode). valid values true or false, default false

    createdTime String

    The date this resource was created.

    destinationConfig Property Map

    Configuration block with destination configuration. See destination_config below.

    functionName String

    Name of the Function Compute Function.

    lastModifiedTime String

    The date this resource was last modified.

    maximumEventAgeInSeconds Number

    Maximum age of a request that Function Compute sends to a function for processing in seconds. Valid values between 1 and 2592000 (between 60 and 21600 before v1.167.0).

    maximumRetryAttempts Number

    Maximum number of times to retry when the function returns an error. Valid values between 0 and 8 (between 0 and 2 before v1.167.0). Defaults to 2.

    qualifier String

    Function Compute Function published version, LATEST, or Function Compute Alias name. The default value is LATEST.

    serviceName String

    Name of the Function Compute Function, omitting any version or alias qualifier.

    statefulInvocation Boolean

    Function Compute async job configuration(also known as Task Mode). valid values true or false, default false

    Supporting Types

    FunctionAsyncInvokeConfigDestinationConfig, FunctionAsyncInvokeConfigDestinationConfigArgs

    OnFailure Pulumi.AliCloud.FC.Inputs.FunctionAsyncInvokeConfigDestinationConfigOnFailure

    Configuration block with destination configuration for failed asynchronous invocations. See on_failure below.

    OnSuccess Pulumi.AliCloud.FC.Inputs.FunctionAsyncInvokeConfigDestinationConfigOnSuccess

    Configuration block with destination configuration for successful asynchronous invocations. See on_success below.

    OnFailure FunctionAsyncInvokeConfigDestinationConfigOnFailure

    Configuration block with destination configuration for failed asynchronous invocations. See on_failure below.

    OnSuccess FunctionAsyncInvokeConfigDestinationConfigOnSuccess

    Configuration block with destination configuration for successful asynchronous invocations. See on_success below.

    onFailure FunctionAsyncInvokeConfigDestinationConfigOnFailure

    Configuration block with destination configuration for failed asynchronous invocations. See on_failure below.

    onSuccess FunctionAsyncInvokeConfigDestinationConfigOnSuccess

    Configuration block with destination configuration for successful asynchronous invocations. See on_success below.

    onFailure FunctionAsyncInvokeConfigDestinationConfigOnFailure

    Configuration block with destination configuration for failed asynchronous invocations. See on_failure below.

    onSuccess FunctionAsyncInvokeConfigDestinationConfigOnSuccess

    Configuration block with destination configuration for successful asynchronous invocations. See on_success below.

    on_failure FunctionAsyncInvokeConfigDestinationConfigOnFailure

    Configuration block with destination configuration for failed asynchronous invocations. See on_failure below.

    on_success FunctionAsyncInvokeConfigDestinationConfigOnSuccess

    Configuration block with destination configuration for successful asynchronous invocations. See on_success below.

    onFailure Property Map

    Configuration block with destination configuration for failed asynchronous invocations. See on_failure below.

    onSuccess Property Map

    Configuration block with destination configuration for successful asynchronous invocations. See on_success below.

    FunctionAsyncInvokeConfigDestinationConfigOnFailure, FunctionAsyncInvokeConfigDestinationConfigOnFailureArgs

    Destination string

    Alicloud Resource Name (ARN) of the destination resource. See the Developer Guide for acceptable resource types and associated RAM permissions.

    Destination string

    Alicloud Resource Name (ARN) of the destination resource. See the Developer Guide for acceptable resource types and associated RAM permissions.

    destination String

    Alicloud Resource Name (ARN) of the destination resource. See the Developer Guide for acceptable resource types and associated RAM permissions.

    destination string

    Alicloud Resource Name (ARN) of the destination resource. See the Developer Guide for acceptable resource types and associated RAM permissions.

    destination str

    Alicloud Resource Name (ARN) of the destination resource. See the Developer Guide for acceptable resource types and associated RAM permissions.

    destination String

    Alicloud Resource Name (ARN) of the destination resource. See the Developer Guide for acceptable resource types and associated RAM permissions.

    FunctionAsyncInvokeConfigDestinationConfigOnSuccess, FunctionAsyncInvokeConfigDestinationConfigOnSuccessArgs

    Destination string

    Alicloud Resource Name (ARN) of the destination resource. See the Developer Guide for acceptable resource types and associated RAM permissions.

    Destination string

    Alicloud Resource Name (ARN) of the destination resource. See the Developer Guide for acceptable resource types and associated RAM permissions.

    destination String

    Alicloud Resource Name (ARN) of the destination resource. See the Developer Guide for acceptable resource types and associated RAM permissions.

    destination string

    Alicloud Resource Name (ARN) of the destination resource. See the Developer Guide for acceptable resource types and associated RAM permissions.

    destination str

    Alicloud Resource Name (ARN) of the destination resource. See the Developer Guide for acceptable resource types and associated RAM permissions.

    destination String

    Alicloud Resource Name (ARN) of the destination resource. See the Developer Guide for acceptable resource types and associated RAM permissions.

    Import

    Function Compute Function Async Invoke Configs can be imported using the id, e.g.

     $ pulumi import alicloud:fc/functionAsyncInvokeConfig:FunctionAsyncInvokeConfig example my_function
    

    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.44.0 published on Thursday, Sep 28, 2023 by Pulumi