Skip to content

Commit a2a852a

Browse files
Merge pull request #13 from aws-samples/securing-acls
Securing acls
2 parents 39e216c + b8fa239 commit a2a852a

6 files changed

Lines changed: 50 additions & 21 deletions

File tree

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,17 @@ test-cfn:
2929

3030
version:
3131
@echo $(shell cfn-flip templates/main.yaml | python -c 'import sys, json; print(json.load(sys.stdin)["Mappings"]["Solution"]["Constants"]["Version"])')
32+
33+
package:
34+
zip -r packaged.zip templates backend cfn-publish.config build.zip -x **/__pycache* -x *settings.js
35+
36+
build-static:
37+
cd source/witch/ && npm install --prefix nodejs mime-types && cp witch.js nodejs/node_modules/
38+
39+
package-static:
40+
make build-static
41+
cd source/witch && zip -r ../../witch.zip nodejs
42+
43+
package-function:
44+
make package-static
45+
cd source/secured-headers/ && zip -r ../../s-headers.zip index.js

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ To deploy the solution, you use [AWS CloudFormation](https://aws.amazon.com/clou
5555

5656
> **Note:** You must have IAM permissions to launch CloudFormation templates that create IAM roles, and to create all the AWS resources in the solution. Also, you are responsible for the cost of the AWS services used while running this solution. For more information about costs, see the pricing pages for each AWS service.
5757
58+
The solution also involves setting the
5859
### Use the CloudFormation console
5960

6061
**To deploy the solution using the CloudFormation console**
@@ -89,6 +90,39 @@ To download the CloudFormation template to deploy on your own, for example by [u
8990

9091
https://s3.amazonaws.com/solution-builders-us-east-1/amazon-cloudfront-secure-static-site/latest/main.yaml
9192

93+
### Updating the Project
94+
95+
If you would like to customise the project and upload your own static website content you can do so by following these steps
96+
97+
1. Ensure that you have npm installed. See instructions [here](https://www.npmjs.com/get-npm)
98+
2. Clone or download the project at [https://github.com/awslabs/aws-cloudformation-templates](https://github.com/awslabs/aws-cloudformation-templates)
99+
3. Package a build artefact by running the following at the command line
100+
101+
```shell
102+
make package-function
103+
```
104+
4. Copy your site content to the projects **www** folder
105+
4. If you don't have one already, create an S3 bucket to store the CloudFormation artifacts with `aws s3 mb s3://<bucket name>`
106+
107+
5. Package the CloudFormation template. The provided template uses [the AWS Serverless Application Model](https://aws.amazon.com/about-aws/whats-new/2016/11/introducing-the-aws-serverless-application-model/) so must be transformed before you can deploy it.
108+
109+
```shell
110+
aws cloudformation package \
111+
--template-file templates/main.yaml \
112+
--s3-bucket <your bucket name here> \
113+
--output-template-file packaged.template
114+
```
115+
116+
6. Deploy the packaged CloudFormation template to a CloudFormation stack:
117+
118+
```shell
119+
aws cloudformation deploy \
120+
--stack-name <your stack name> \
121+
--template-file packaged.template \
122+
--capabilities CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND \
123+
--parameter-overrides DomainName=<your domain> SubDomain=<your subdomain>
124+
```
125+
92126
## Contributing
93127
Contributions are welcome. Please read the [code of conduct](CODE_OF_CONDUCT.md) and the [contributing guidelines](CONTRIBUTING.md).
94128

docs/images/architecture.png

-3.34 KB
Loading

source/witch/nodejs/package-lock.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

source/witch/witch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ exports.staticHandler = function(event, context) {
2525
Bucket: BUCKET,
2626
ContentType: fileType,
2727
Key: file,
28-
ACL: "public-read",
28+
ACL: "private",
2929
}).promise();
3030
})).then((msg) => {
3131
respond(event, context, SUCCESS, {Message: msg});

templates/custom-resource.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Resources:
9292
SSEAlgorithm: AES256
9393
LoggingConfiguration:
9494
DestinationBucketName: !Ref 'S3BucketLogs'
95-
LogFilePrefix: 'cdn/'
95+
LogFilePrefix: 'origin/'
9696
Tags:
9797
- Key: Solution
9898
Value: ACFS3

0 commit comments

Comments
 (0)