Skip to content

Task 2 #557

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BUCKET_NAME=infrastack-websitebucket75c24d94-zfidwtrac5aw
DISTRIBUTION_ID=E1L4KL50AHHB3I
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# React-shop-cloudfront
https://d1viw7rdmpypnj.cloudfront.net
http://infrastack-websitebucket75c24d94-frjac1vdwswk.s3-website.eu-north-1.amazonaws.com

This is frontend starter project for nodejs-aws mentoring program. It uses the following technologies:

Expand Down
7 changes: 7 additions & 0 deletions cdk-outputs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"InfraStack": {
"BucketName": "infrastack-websitebucket75c24d94-zfidwtrac5aw",
"CloudFrontURL": "d1viw7rdmpypnj.cloudfront.net",
"DistributionId": "E1L4KL50AHHB3I"
}
}
20 changes: 20 additions & 0 deletions cdk.out/InfraStack.assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "40.0.0",
"files": {
"12901e29450b54ae9afe2292dc76d541d21b5efdf5194cf68fa21ae3ac24c09e": {
"source": {
"path": "InfraStack.template.json",
"packaging": "file"
},
"destinations": {
"current_account-eu-north-1": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-eu-north-1",
"objectKey": "12901e29450b54ae9afe2292dc76d541d21b5efdf5194cf68fa21ae3ac24c09e.json",
"region": "eu-north-1",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-eu-north-1"
}
}
}
},
"dockerImages": {}
}
168 changes: 168 additions & 0 deletions cdk.out/InfraStack.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
{
"Resources": {
"WebsiteBucket75C24D94": {
"Type": "AWS::S3::Bucket",
"Properties": {
"PublicAccessBlockConfiguration": {
"BlockPublicAcls": true,
"IgnorePublicAcls": true
},
"WebsiteConfiguration": {
"IndexDocument": "index.html"
}
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain",
"Metadata": {
"aws:cdk:path": "InfraStack/WebsiteBucket/Resource"
}
},
"WebsiteBucketPolicyE10E3262": {
"Type": "AWS::S3::BucketPolicy",
"Properties": {
"Bucket": {
"Ref": "WebsiteBucket75C24D94"
},
"PolicyDocument": {
"Statement": [
{
"Action": "s3:GetObject",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Resource": {
"Fn::Join": [
"",
[
{
"Fn::GetAtt": [
"WebsiteBucket75C24D94",
"Arn"
]
},
"/*"
]
]
}
}
],
"Version": "2012-10-17"
}
},
"Metadata": {
"aws:cdk:path": "InfraStack/WebsiteBucket/Policy/Resource"
}
},
"WebsiteDistribution75DCDA0B": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
"DefaultCacheBehavior": {
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
"Compress": true,
"TargetOriginId": "InfraStackWebsiteDistributionOrigin1B6920153",
"ViewerProtocolPolicy": "redirect-to-https"
},
"Enabled": true,
"HttpVersion": "http2",
"IPV6Enabled": true,
"Origins": [
{
"CustomOriginConfig": {
"OriginProtocolPolicy": "http-only",
"OriginSSLProtocols": [
"TLSv1.2"
]
},
"DomainName": {
"Fn::Select": [
2,
{
"Fn::Split": [
"/",
{
"Fn::GetAtt": [
"WebsiteBucket75C24D94",
"WebsiteURL"
]
}
]
}
]
},
"Id": "InfraStackWebsiteDistributionOrigin1B6920153"
}
],
"PriceClass": "PriceClass_100"
}
},
"Metadata": {
"aws:cdk:path": "InfraStack/WebsiteDistribution/Resource"
}
},
"CDKMetadata": {
"Type": "AWS::CDK::Metadata",
"Properties": {
"Analytics": "v2:deflate64:H4sIAAAAAAAA/02KwQ7CIBAFv6V3upYajWf1XqMfYCjQZAuCgcXGEP7dNJjoad5MXg/8sIeuEUtspTKtxRHyjYQ0TCzxnuMW8jFJo4mdJvddFRdvUb5/uXph0vqkpuAdQT5jpIBjIvRuff57KWsZEj0TFea80jDHzavvgO+AN3NEbENyhA8N18oPxME7s64AAAA="
},
"Metadata": {
"aws:cdk:path": "InfraStack/CDKMetadata/Default"
}
}
},
"Outputs": {
"BucketName": {
"Value": {
"Ref": "WebsiteBucket75C24D94"
}
},
"DistributionId": {
"Value": {
"Ref": "WebsiteDistribution75DCDA0B"
}
},
"CloudFrontURL": {
"Value": {
"Fn::GetAtt": [
"WebsiteDistribution75DCDA0B",
"DomainName"
]
}
}
},
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}
1 change: 1 addition & 0 deletions cdk.out/cdk.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"40.0.0"}
101 changes: 101 additions & 0 deletions cdk.out/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"version": "40.0.0",
"artifacts": {
"InfraStack.assets": {
"type": "cdk:asset-manifest",
"properties": {
"file": "InfraStack.assets.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"InfraStack": {
"type": "aws:cloudformation:stack",
"environment": "aws://unknown-account/eu-north-1",
"properties": {
"templateFile": "InfraStack.template.json",
"terminationProtection": false,
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-eu-north-1",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-eu-north-1",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-eu-north-1/12901e29450b54ae9afe2292dc76d541d21b5efdf5194cf68fa21ae3ac24c09e.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
"InfraStack.assets"
],
"lookupRole": {
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-eu-north-1",
"requiresBootstrapStackVersion": 8,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"dependencies": [
"InfraStack.assets"
],
"metadata": {
"/InfraStack/WebsiteBucket/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "WebsiteBucket75C24D94"
}
],
"/InfraStack/WebsiteBucket/Policy/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "WebsiteBucketPolicyE10E3262"
}
],
"/InfraStack/WebsiteDistribution/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "WebsiteDistribution75DCDA0B"
}
],
"/InfraStack/BucketName": [
{
"type": "aws:cdk:logicalId",
"data": "BucketName"
}
],
"/InfraStack/DistributionId": [
{
"type": "aws:cdk:logicalId",
"data": "DistributionId"
}
],
"/InfraStack/CloudFrontURL": [
{
"type": "aws:cdk:logicalId",
"data": "CloudFrontURL"
}
],
"/InfraStack/CDKMetadata/Default": [
{
"type": "aws:cdk:logicalId",
"data": "CDKMetadata"
}
],
"/InfraStack/BootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "BootstrapVersion"
}
],
"/InfraStack/CheckBootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "CheckBootstrapVersion"
}
]
},
"displayName": "InfraStack"
},
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
}
}
}
1 change: 1 addition & 0 deletions cdk.out/tree.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"tree-0.1","tree":{"id":"App","path":"","children":{"InfraStack":{"id":"InfraStack","path":"InfraStack","children":{"WebsiteBucket":{"id":"WebsiteBucket","path":"InfraStack/WebsiteBucket","children":{"Resource":{"id":"Resource","path":"InfraStack/WebsiteBucket/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::S3::Bucket","aws:cdk:cloudformation:props":{"publicAccessBlockConfiguration":{"blockPublicAcls":true,"ignorePublicAcls":true},"websiteConfiguration":{"indexDocument":"index.html"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_s3.CfnBucket","version":"2.186.0"}},"Policy":{"id":"Policy","path":"InfraStack/WebsiteBucket/Policy","children":{"Resource":{"id":"Resource","path":"InfraStack/WebsiteBucket/Policy/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::S3::BucketPolicy","aws:cdk:cloudformation:props":{"bucket":{"Ref":"WebsiteBucket75C24D94"},"policyDocument":{"Statement":[{"Action":"s3:GetObject","Effect":"Allow","Principal":{"AWS":"*"},"Resource":{"Fn::Join":["",[{"Fn::GetAtt":["WebsiteBucket75C24D94","Arn"]},"/*"]]}}],"Version":"2012-10-17"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_s3.CfnBucketPolicy","version":"2.186.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_s3.BucketPolicy","version":"2.186.0","metadata":[]}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_s3.Bucket","version":"2.186.0","metadata":[]}},"WebsiteDistribution":{"id":"WebsiteDistribution","path":"InfraStack/WebsiteDistribution","children":{"Origin1":{"id":"Origin1","path":"InfraStack/WebsiteDistribution/Origin1","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"Resource":{"id":"Resource","path":"InfraStack/WebsiteDistribution/Resource","attributes":{"aws:cdk:cloudformation:type":"AWS::CloudFront::Distribution","aws:cdk:cloudformation:props":{"distributionConfig":{"enabled":true,"origins":[{"domainName":{"Fn::Select":[2,{"Fn::Split":["/",{"Fn::GetAtt":["WebsiteBucket75C24D94","WebsiteURL"]}]}]},"id":"InfraStackWebsiteDistributionOrigin1B6920153","customOriginConfig":{"originSslProtocols":["TLSv1.2"],"originProtocolPolicy":"http-only"}}],"defaultCacheBehavior":{"pathPattern":"*","targetOriginId":"InfraStackWebsiteDistributionOrigin1B6920153","cachePolicyId":"658327ea-f89d-4fab-a63d-7e88639e58f6","compress":true,"viewerProtocolPolicy":"redirect-to-https"},"httpVersion":"http2","ipv6Enabled":true,"priceClass":"PriceClass_100"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_cloudfront.CfnDistribution","version":"2.186.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.aws_cloudfront.Distribution","version":"2.186.0","metadata":[]}},"BucketName":{"id":"BucketName","path":"InfraStack/BucketName","constructInfo":{"fqn":"aws-cdk-lib.CfnOutput","version":"2.186.0"}},"DistributionId":{"id":"DistributionId","path":"InfraStack/DistributionId","constructInfo":{"fqn":"aws-cdk-lib.CfnOutput","version":"2.186.0"}},"CloudFrontURL":{"id":"CloudFrontURL","path":"InfraStack/CloudFrontURL","constructInfo":{"fqn":"aws-cdk-lib.CfnOutput","version":"2.186.0"}},"CDKMetadata":{"id":"CDKMetadata","path":"InfraStack/CDKMetadata","children":{"Default":{"id":"Default","path":"InfraStack/CDKMetadata/Default","constructInfo":{"fqn":"aws-cdk-lib.CfnResource","version":"2.186.0"}}},"constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}},"BootstrapVersion":{"id":"BootstrapVersion","path":"InfraStack/BootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnParameter","version":"2.186.0"}},"CheckBootstrapVersion":{"id":"CheckBootstrapVersion","path":"InfraStack/CheckBootstrapVersion","constructInfo":{"fqn":"aws-cdk-lib.CfnRule","version":"2.186.0"}}},"constructInfo":{"fqn":"aws-cdk-lib.Stack","version":"2.186.0"}},"Tree":{"id":"Tree","path":"Tree","constructInfo":{"fqn":"constructs.Construct","version":"10.4.2"}}},"constructInfo":{"fqn":"aws-cdk-lib.App","version":"2.186.0"}}}
8 changes: 8 additions & 0 deletions infra/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.js
!jest.config.js
*.d.ts
node_modules

# CDK asset staging directory
.cdk.staging
cdk.out
6 changes: 6 additions & 0 deletions infra/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.ts
!*.d.ts

# CDK asset staging directory
.cdk.staging
cdk.out
14 changes: 14 additions & 0 deletions infra/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Welcome to your CDK TypeScript project

This is a blank project for CDK development with TypeScript.

The `cdk.json` file tells the CDK Toolkit how to execute your app.

## Useful commands

* `npm run build` compile typescript to js
* `npm run watch` watch for changes and compile
* `npm run test` perform the jest unit tests
* `npx cdk deploy` deploy this stack to your default AWS account/region
* `npx cdk diff` compare deployed stack with current state
* `npx cdk synth` emits the synthesized CloudFormation template
20 changes: 20 additions & 0 deletions infra/bin/infra.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node
import * as cdk from 'aws-cdk-lib';
import { InfraStack } from '../lib/infra-stack';

const app = new cdk.App();
new InfraStack(app, 'InfraStack', {
/* If you don't specify 'env', this stack will be environment-agnostic.
* Account/Region-dependent features and context lookups will not work,
* but a single synthesized template can be deployed anywhere. */

/* Uncomment the next line to specialize this stack for the AWS Account
* and Region that are implied by the current CLI configuration. */
// env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION },

/* Uncomment the next line if you know exactly what Account and Region you
* want to deploy the stack to. */
env: { region: 'eu-north-1' },

/* For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html */
});
Loading