mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
provider/aws: Allow importing lambda_function (#7610)
This commit is contained in:
parent
6468b899b9
commit
b8d21330a7
81
builtin/providers/aws/import_aws_lambda_function_test.go
Normal file
81
builtin/providers/aws/import_aws_lambda_function_test.go
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
package aws
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAccAWSLambdaFunction_importLocalFile(t *testing.T) {
|
||||||
|
resourceName := "aws_lambda_function.lambda_function_test"
|
||||||
|
|
||||||
|
rName := fmt.Sprintf("tf_test_%s", acctest.RandString(5))
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckLambdaFunctionDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccAWSLambdaConfigBasic(rName),
|
||||||
|
},
|
||||||
|
|
||||||
|
resource.TestStep{
|
||||||
|
ResourceName: resourceName,
|
||||||
|
ImportState: true,
|
||||||
|
ImportStateVerify: true,
|
||||||
|
ImportStateVerifyIgnore: []string{"filename"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAccAWSLambdaFunction_importLocalFile_VPC(t *testing.T) {
|
||||||
|
resourceName := "aws_lambda_function.lambda_function_test"
|
||||||
|
|
||||||
|
rName := fmt.Sprintf("tf_test_%s", acctest.RandString(5))
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckLambdaFunctionDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccAWSLambdaConfigWithVPC(rName),
|
||||||
|
},
|
||||||
|
|
||||||
|
resource.TestStep{
|
||||||
|
ResourceName: resourceName,
|
||||||
|
ImportState: true,
|
||||||
|
ImportStateVerify: true,
|
||||||
|
ImportStateVerifyIgnore: []string{"filename"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAccAWSLambdaFunction_importS3(t *testing.T) {
|
||||||
|
resourceName := "aws_lambda_function.lambda_function_s3test"
|
||||||
|
|
||||||
|
rName := fmt.Sprintf("tf_test_%s", acctest.RandString(5))
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckLambdaFunctionDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccAWSLambdaConfigS3(rName),
|
||||||
|
},
|
||||||
|
|
||||||
|
resource.TestStep{
|
||||||
|
ResourceName: resourceName,
|
||||||
|
ImportState: true,
|
||||||
|
ImportStateVerify: true,
|
||||||
|
ImportStateVerifyIgnore: []string{"s3_bucket", "s3_key"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
@ -24,6 +24,13 @@ func resourceAwsLambdaFunction() *schema.Resource {
|
|||||||
Update: resourceAwsLambdaFunctionUpdate,
|
Update: resourceAwsLambdaFunctionUpdate,
|
||||||
Delete: resourceAwsLambdaFunctionDelete,
|
Delete: resourceAwsLambdaFunctionDelete,
|
||||||
|
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
State: func(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
|
||||||
|
d.Set("function_name", d.Id())
|
||||||
|
return []*schema.ResourceData{d}, nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"filename": &schema.Schema{
|
"filename": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
Loading…
Reference in New Issue
Block a user