Skip to content

Commit

Permalink
Add s3 resource to upload files to aws
Browse files Browse the repository at this point in the history
  • Loading branch information
Nishu Goel committed Jan 23, 2024
1 parent c22211a commit 1938380
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 16 deletions.
15 changes: 4 additions & 11 deletions docs/resources/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,10 @@ File Resource

```terraform
resource "epilot-file_file" "my_file" {
access_control = "public-read"
additional_properties = "{ \"see\": \"documentation\" }"
bucket = "epilot-files-prod"
custom_download_url = "https://both-legging.net"
document_type = "archive"
file_entity_id = "...my_file_entity_id..."
filename = "document.pdf"
key = "123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"
tags = [
"...",
]
access_control = "private"
filename = epilot-file_upload_file.my_uploadfile.filename
bucket = epilot-file_upload_file.my_uploadfile.s3ref.bucket
key = epilot-file_upload_file.my_uploadfile.s3ref.key
}
```

Expand Down
26 changes: 23 additions & 3 deletions docs/resources/upload_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,30 @@ UploadFile Resource
## Example Usage

```terraform
# Upload file to S3
resource "epilot-file_upload_file" "my_uploadfile" {
file_entity_id = "ef7d985c-2385-44f4-9c71-ae06a52264f8"
filename = "document.pdf"
mime_type = "application/pdf"
filename = "NishuGoel.png"
mime_type = "image/png"
}
output "uploaded_file" {
value = epilot-file_upload_file.my_uploadfile
}
resource "aws_s3_object" "s3_file_upload" {
bucket = epilot-file_upload_file.my_uploadfile.s3ref.bucket
key = epilot-file_upload_file.my_uploadfile.s3ref.key
source = "/Users/nishugoel/epilot/terraform blueprints/terraform-provider-epilot-file/examples/resources/epilot-file_upload_file/NishuGoel.png"
}
# Save uploaded file
resource "epilot-file_file" "my_file" {
access_control = "private"
filename = epilot-file_upload_file.my_uploadfile.filename
bucket = epilot-file_upload_file.my_uploadfile.s3ref.bucket
key = epilot-file_upload_file.my_uploadfile.s3ref.key
entity_id = ""
}
```

Expand Down
8 changes: 8 additions & 0 deletions examples/resources/epilot-file_upload_file/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ terraform {
source = "epilot-dev/epilot-file"
version = "2.1.1"
}
aws = {
source = "hashicorp/aws"
version = "5.33.0"
}
}
}

Expand All @@ -16,4 +20,8 @@ variable epilot_auth {
provider "epilot-file" {
# Configuration options
epilot_auth = var.epilot_auth
}

provider "aws" {
# Configuration options
}
11 changes: 9 additions & 2 deletions examples/resources/epilot-file_upload_file/resource.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
# Upload file to S3
resource "epilot-file_upload_file" "my_uploadfile" {
filename = "pumpkin.png"
filename = "NishuGoel.png"
mime_type = "image/png"
}

output "val" {
output "uploaded_file" {
value = epilot-file_upload_file.my_uploadfile
}


resource "aws_s3_object" "s3_file_upload" {
bucket = epilot-file_upload_file.my_uploadfile.s3ref.bucket
key = epilot-file_upload_file.my_uploadfile.s3ref.key
source = "/Users/nishugoel/epilot/terraform blueprints/terraform-provider-epilot-file/examples/resources/epilot-file_upload_file/NishuGoel.png"
}

# Save uploaded file
resource "epilot-file_file" "my_file" {
access_control = "private"
filename = epilot-file_upload_file.my_uploadfile.filename
bucket = epilot-file_upload_file.my_uploadfile.s3ref.bucket
key = epilot-file_upload_file.my_uploadfile.s3ref.key
entity_id = ""
}


0 comments on commit 1938380

Please sign in to comment.