Unable to Reference a S3 file in Terraform

Lakshay Kashyap

I have a S3 file called python.zip already uploaded which Im trying to reference to add it in Lambda Layer. I am using aws_s3_object data/resource in Terraform but it is erroring out no matter what I do.

** Error: Invalid data source

on main.tf line 12, in data "aws_S3_object" "layer_object": 12: data "aws_S3_object" "layer_object" {

The provider provider.aws does not support data source "aws_S3_object". **

Below Terraform code that I am using.

terraform {
  backend s3 {
    key             = "InstanceCleanup.tfstate"
    dynamodb_table  = "terraform-state-locking"
  }
}

provider "aws" {
  region = "us-east-1"
}

data "aws_S3_object" "layer_object" {
  bucket = "agent-buildup-806471337920"
  key    = "python.zip"
 }

resource "aws_lambda_layer_version" "my_layer" {
  filename            = "python.zip"
  layer_name          = "Requests-2.31.0"
  description         = "Requests module for python 3.8 compatibilty"
  compatible_runtimes = ["python3.8"]
  s3_bucket           = data.aws_S3_object.layer_object.bucket
  s3_key              = data.aws_S3_object.layer_object.key
}

## Lambda Function ##
resource "aws_lambda_function" "Instance_Cleanup" {
  function_name = "Instance-Cleanup-function"
  handler       = "Instance-Cleanup.lambda_handler"
  runtime       = "python3.8"
  filename      = "Instance-Cleanup.zip"
  timeout       = 10
  role          = aws_iam_role.Lambda_role.arn

  layers = [aws_lambda_layer_version.my_layer.arn]
  
  source_code_hash = filebase64sha256("Instance-Cleanup.zip")

  environment {
    variables = {
      pool_ids        = join(",", var.pool_ids)
      instance_names  = join(",", var.instance_names)
    }
  }

}

Help me guys !!!!

Mark B

The data source name is aws_s3_object, with a lower case s3, not aws_S3_object.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to reference a zip file uploaded in an s3 bucket in your terraform lambda code?

From Dev

Unable to create a s3 bucket with versioning using terraform

From Dev

Unable to retrieve terraform state as S3 bucket deleted

From Dev

terraform to generate a file, zip and upload to s3

From Dev

Terraform - Upload file to S3 on every apply

From Dev

using terraform template_file and s3 to bootstrap with s3

From Dev

Fab file, unable to remote curl a S3 .gzip file

From Dev

Reference S3 file upload name in new mongoDB object

From Dev

Unable to fetch file from s3 with api

From Dev

Unable to set file content type in S3

From Dev

AWS Lambda unable to GET a file from S3

From Dev

unable to upload image file to S3 bucket via PHP

From Dev

Unable to download a file from S3 by the URL in a browser

From Dev

Unable to upload a pdf file to AWS s3 bucket - PHP

From Dev

AWS related questions with terraform: unable to create s3 bucket notification to AWS SNS

From Dev

Unable to add versioning_configuration for multiple aws s3 in terraform version 4.5.0

From Dev

Unable to see the Terraform provider file after running terraform init

From Dev

Can I configure Terraform to not use "env:" in the path for a workspace's state file path on S3?

From Dev

Unable to reference an AWS API Gateway Usage Plan as a data source in Terraform

From Dev

How to grant lambda permission to upload file to s3 bucket in `terraform`?

From Dev

How to configure `Terraform` to upload zip file to `s3` bucket and then deploy them to lambda

From Dev

How to reference a variable in Terraform file for Azure DevOps/VSTS

From Dev

Unable to restore SQL Server bak file from S3, says file too large

From Dev

Unable to download file from s3 using return response()->download($file);

From Dev

Unable to reference $ref schema from different file

From Dev

Laravel getID3 unable to pull file from S3

From Dev

Unable to upload file to AWS S3 using python boto3 and upload_fileobj

From Dev

File can be uploaded to S3 locally but can't within a container (Unable to locate credential)

From Dev

Unable to upload file to S3 with Python using IAM role credentials

Related Related

  1. 1

    How to reference a zip file uploaded in an s3 bucket in your terraform lambda code?

  2. 2

    Unable to create a s3 bucket with versioning using terraform

  3. 3

    Unable to retrieve terraform state as S3 bucket deleted

  4. 4

    terraform to generate a file, zip and upload to s3

  5. 5

    Terraform - Upload file to S3 on every apply

  6. 6

    using terraform template_file and s3 to bootstrap with s3

  7. 7

    Fab file, unable to remote curl a S3 .gzip file

  8. 8

    Reference S3 file upload name in new mongoDB object

  9. 9

    Unable to fetch file from s3 with api

  10. 10

    Unable to set file content type in S3

  11. 11

    AWS Lambda unable to GET a file from S3

  12. 12

    unable to upload image file to S3 bucket via PHP

  13. 13

    Unable to download a file from S3 by the URL in a browser

  14. 14

    Unable to upload a pdf file to AWS s3 bucket - PHP

  15. 15

    AWS related questions with terraform: unable to create s3 bucket notification to AWS SNS

  16. 16

    Unable to add versioning_configuration for multiple aws s3 in terraform version 4.5.0

  17. 17

    Unable to see the Terraform provider file after running terraform init

  18. 18

    Can I configure Terraform to not use "env:" in the path for a workspace's state file path on S3?

  19. 19

    Unable to reference an AWS API Gateway Usage Plan as a data source in Terraform

  20. 20

    How to grant lambda permission to upload file to s3 bucket in `terraform`?

  21. 21

    How to configure `Terraform` to upload zip file to `s3` bucket and then deploy them to lambda

  22. 22

    How to reference a variable in Terraform file for Azure DevOps/VSTS

  23. 23

    Unable to restore SQL Server bak file from S3, says file too large

  24. 24

    Unable to download file from s3 using return response()->download($file);

  25. 25

    Unable to reference $ref schema from different file

  26. 26

    Laravel getID3 unable to pull file from S3

  27. 27

    Unable to upload file to AWS S3 using python boto3 and upload_fileobj

  28. 28

    File can be uploaded to S3 locally but can't within a container (Unable to locate credential)

  29. 29

    Unable to upload file to S3 with Python using IAM role credentials

HotTag

Archive