Skip to content

feat: PHP + S3 example #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 2023
Merged

feat: PHP + S3 example #32

merged 3 commits into from
Apr 11, 2023

Conversation

Shillaker
Copy link
Contributor

@Shillaker Shillaker commented Apr 5, 2023

Summary

Demonstration using PHP and S3 via the AWS PHP SDK.

Checklist

  • I have reviewed this myself.
  • I have attached a README to my example. You can use this template as reference.
  • I have updated the project README to link my example.

@Shillaker Shillaker self-assigned this Apr 5, 2023
@Shillaker Shillaker changed the title Add simple PHP S3 example Add PHP + S3 example Apr 6, 2023
@Shillaker Shillaker changed the title Add PHP + S3 example (feat): PHP + S3 example Apr 6, 2023
@Shillaker Shillaker changed the title (feat): PHP + S3 example feat: PHP + S3 example Apr 6, 2023
update = "15m"
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use Terraform to zip the function directly:

Suggested change
data "archive_file" "function_archive" {
type = "zip"
source_dir = "${path.module}/../function/"
output_file_mode = "0666"
output_path = "${path.module}/../function/function.zip"

And then add this to the function resource:

zip_file = data.archive_file.function_archive.output_path
zip_hash = data.archive_file.function_archive.output_sha

Stolen from here: https://github.com/scaleway/serverless-examples/blob/main/functions/redis-tls/terraform/main.tf

But a MakeFile is good also because it explains better how to zip 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, I think I will switch to TF because otherwise we're making another assumption about the environment and existence of a zip command.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ☺️ ! For even more Terraform goodness 🍬 you could generate an IAM S3 scoped API key with Terraform as well
Some examples:
Generating the key: https://github.com/cyclimse/severless-pypi/blob/main/deploying/terraform/iam.tf
And passing it to a container: https://github.com/cyclimse/severless-pypi/blob/main/deploying/terraform/main.tf#L57

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to keep this as simple as possible, so will leave it for now but will remember for later!

@Shillaker Shillaker merged commit 638a763 into main Apr 11, 2023
@Shillaker Shillaker deleted the php-hello-world branch November 10, 2023 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants