Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@arc-iac/tf-cdk-spa
Advanced tools
This repository contains code that demonstrates how to deploy a Single-Page Application (SPA) to Amazon Web Services (AWS) S3 and CloudFront using Cloud Development Kit for Terraform (CDKTF) for TypeScript. The deployment process involves creating an S3 b
This repository contains code that demonstrates how to deploy a Single-Page Application (SPA) to Amazon Web Services (AWS) S3 and CloudFront using Cloud Development Kit for Terraform (CDKTF) for TypeScript. The deployment process involves creating an S3 bucket, configuring CloudFront distribution, setting up DNS with Route 53, and uploading the SPA files to the S3 bucket.
Before you begin, make sure you have the following prerequisites:
The deployment process relies on several environment variables. Create a .env
file in the root directory of the project and set the following environment variables:
Environment Variable | Default Value | Description |
---|---|---|
AWS_REGION | us-east-1 | AWS region where the infrastructure will be deployed |
AWS_PROFILE | default | AWS profile to use for authentication and authorization |
S3_BUCKET_NAME | N/A | Name of the S3 bucket that will store the SPA files |
CUSTOM_DOMAIN | N/A | Custom domain for the SPA |
HOSTED_ZONE_ID | N/A | ID of the Route 53 hosted zone for the custom domain |
RELATIVE_PATH_TO_BUILD_DIR | ../build | Relative path to the SPA build directory (default: ../build ) |
If any of the variables are not provided, the default values mentioned above will be used.
Follow these steps to deploy the SPA to AWS:
Navigate to this project (cdk) directory.
Install dependencies:
npm install
Generate CDK Constructs for Terraform providers and modules.:
cdktf get
Please note that the original project relies solely on the AWS provider, which is installed as an npm dependency. Therefore, when you run cdktf get
, you may encounter the following message: default - WARNING: No providers or modules found in 'cdktf.json' config file, therefore cdktf get does nothing.
However, if you make any customizations to the code and add additional providers or modules to the cdktf.json
file, it is important to run cdktf get
before deploying your stack to AWS. This command ensures that all the required providers and modules are fetched and available for use in your infrastructure deployment.
Generate the Terraform configuration by running:
cdktf synth
Deploy the infrastructure:
cdktf deploy spa-host
This command will use Terraform and CDK to create the necessary resources on AWS based on the code in main.ts
. The deployment process may take a few minutes to complete.
Please note that the stack name defined in the main.ts
file is spa-host
. If you have made any customizations to the stacks and have multiple stacks defined, it is important to run the cdktf deploy
command with the appropriate stack name.
If you have a single stack named spa-host
, you can simply run cdktf deploy spa-host
to deploy that specific stack. However, if you have multiple stacks, you need to run cdktf deploy <stack-name>
for each stack to ensure they are deployed correctly. Replace <stack-name>
with the actual name of the stack you want to deploy.
Verify the deployment:
Once the deployment is successful, you can access your SPA using the custom domain specified in the CUSTOM_DOMAIN
environment variable.
Please note that it may take some time for CloudFront to become fully available after deployment, and during this period, you may encounter an AccessDenied
error. This is a normal part of the CloudFront provisioning process.
To resolve this issue, I recommend being patient and waiting for approximately 15-20 minutes before accessing your resources through CloudFront. This will allow sufficient time for the necessary configurations and distributions to be set up properly.
You can customize the deployment by modifying the main.ts
file according to your requirements. Update the code to include additional AWS resources or modify the existing ones.
To clean up and delete the deployed resources from AWS, run the following command:
cdktf destroy spa-host
This command will use Terraform to destroy the infrastructure created during the deployment process. Confirm the destruction when prompted. Please note that if you have made customizations to the code, make sure to replace spa-host with the names of your stacks.
This code is licensed under the MPL-2.0 license.
FAQs
Simplify the deployment of your static websites and Single-Page Applications (SPAs) to Amazon Web Services (AWS) S3 and CloudFront using the Cloud Development Kit for Terraform (CDKTF) with TypeScript. This package leverages the power of the Cloud Develop
The npm package @arc-iac/tf-cdk-spa receives a total of 2 weekly downloads. As such, @arc-iac/tf-cdk-spa popularity was classified as not popular.
We found that @arc-iac/tf-cdk-spa demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.