简体   繁体   English

Terraform相当于CloudFormation中的Custom :: LoadLambda

[英]Terraform equiv to Custom::LoadLambda in CloudFormation

I know the equivalent to AWS::Lambda::Function is aws_lambda_function 我知道相当于AWS::Lambda::Functionaws_lambda_function

But I'm not sure what the equiv for Custom::LoadLambda 但是我不确定Custom::LoadLambda

I'm trying to translate the below into Terraform: 我正在尝试将以下内容转换为Terraform:

CreateRsaKey:
    Type: Custom::LoadLambda
    Properties:
      ServiceToken: # This seems to call another lambda
        Fn::GetAtt:
        - SolutionHelper
        - Arn
      Region:
        Ref: AWS::Region

The Custom::String Resource Type refers to a Custom Resource . Custom::String资源类型是指Custom Resource This means that what it does depends on the particular implementation of the Lambda function provided to the ServiceToken property ( SolutionHelper in your example). 这意味着它的作用取决于提供给ServiceToken属性(在您的示例中为SolutionHelper )的Lambda函数的特定实现。 When a Custom Resource is used, the Lambda function is invoked with a Request Object specifying a RequestType of Create / Update / Delete . 使用自定义资源时,Lambda函数将与请求对象一起调用,该对象指定了Create / Update / DeleteRequestType

The Terraform equivalent of a Custom Resource is a Custom Provider plugin. 相当于自定义资源的Terraform是一个自定义提供程序插件。 These are packaged and distributed the same as the standard set of Providers, only less officially. 这些打包和分发的方式与标准提供者的分发方式相同,只是正式程度较低。 They are built as separate binaries (typically Go packages) auto-discovered by the core Terraform process using a filename convention ( terraform-<TYPE>-<NAME> ), and are invoked in a subprocess using a custom RPC mechanism . 它们被构建为独立的二进制文件(通常是Go软件包),并由核心Terraform进程使用文件名约定( terraform-<TYPE>-<NAME> )自动发现,并在子进程中使用自定义RPC机制进行调用。 The plugin binary provides through RPC a Provider containing a collection of Resource s that implement Create / Read / Update / Delete functions for the resource. 插件二进制文件通过RPC Provider了一个Provider ,该Provider包含Resource的集合,这些集合实现了该资源的Create / Read / Update / Delete功能。

So it's possible to re-implement the functionality of a Lambda-backed Custom Resource within a Terraform Provider Plugin by translating the CloudFormation Create / Update / Delete logic in the Lambda function to the Create / Update / Delete functions in the Terraform Resource (and adding an appropriate Read function). 因此,可以通过将Lambda函数中的CloudFormation Create / Update / Delete逻辑转换为Terraform ResourceCreate / Update / Delete函数来重新实现Terraform Provider插件中由Lambda支持的自定义资源的功能。适当的Read功能)。 However, it's not a very simple or straightforward process. 但是,这不是一个非常简单或直接的过程。

您可以尝试使用此提供程序https://github.com/mobfox/terraform-provider-multiverse

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM