Install or update the latest version of the AWS CLI https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
Run this command to set your credentials, region, and output format. The following example shows sample values.
> aws configure --profile [YOUR_PROFILE]
AWS Access Key ID [None]: ******
AWS Secret Access Key [None]: ******
Default region name [None]: us-east-1
Default output format [None]: json
To list configuration data, use the aws configure list command.
> aws configure list
> dotnet build -c release
Replace the AWS PROFILE with your own in main.tf.
provider "aws" {
profile = "[YOUR_PROFILE]"
region = "us-east-1"
}
> terraform init
Replace the SNS email address with your own in variables.tf.
variable "sns_email" {
type = string
default = "[YOUR_EMAIL]"
}
> terraform apply
After the Terraform plan execution is complete, look for the outputs to test your API.
Outputs:
- lambda_function_url = "https://<url_id>.lambda-url..on.aws/"
- s3_bucket_name = "ei-bg-api-file-upload"
AWS will send you an email to confirm your subscription to SNS. Click the link in the email to confirm your email address and receive notifications when files are uploaded.
Before destroying, you must remove the uploaded images from the S3 bucket, as AWS policy prohibits deleting non-empty buckets.
You can either use the DeleteFiles endpoint or manually delete the files from the AWS console.
> terraform destroy
To Do:
- Upload zip to s3 vs from file system (3)
- terraform.tfstate is S3
- Clean up main.tf (seperate into modules) and update output.tf (1)
> git filter-branch -f --index-filter 'git rm --cached -r --ignore-unmatch .terraform/'