├── AWS
├── EKSKubernetesManifests
│ ├── AwsUtility.yaml
│ ├── HotelService.yaml
│ ├── IngressService.yaml
│ └── external-dns.yaml
├── HotelSearchServiceFrontEnd
│ ├── .github
│ │ └── workflows
│ │ │ └── node.js.yml
│ ├── .gitignore
│ ├── README.md
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── robots.txt
│ └── src
│ │ ├── App.js
│ │ ├── App.scss
│ │ ├── App.test.js
│ │ ├── components
│ │ ├── booking
│ │ │ └── BookingDetails.js
│ │ ├── hotel
│ │ │ ├── FavoriteHotels.js
│ │ │ ├── HotelDescription.js
│ │ │ ├── HotelFacilities.js
│ │ │ ├── HotelImages.js
│ │ │ ├── HotelList.js
│ │ │ ├── HotelReview.js
│ │ │ ├── HotelTopBar.js
│ │ │ ├── MainReview.js
│ │ │ └── SavedHotel.js
│ │ ├── search
│ │ │ ├── FlightSearch.js
│ │ │ ├── FlightSearchAutoSuggest.js
│ │ │ ├── HotelSearch.js
│ │ │ ├── SearchComponent.js
│ │ │ └── SearchComponent.module.scss
│ │ └── ui
│ │ │ ├── Layout.js
│ │ │ ├── Modal.js
│ │ │ ├── NavBar.js
│ │ │ ├── NavBar.module.scss
│ │ │ └── Themes.js
│ │ ├── hooks
│ │ └── use-http.js
│ │ ├── index.js
│ │ ├── index.scss
│ │ ├── logo.svg
│ │ ├── pages
│ │ ├── FavoriteHotels.js
│ │ ├── FlightBooking.js
│ │ ├── HotelBooking.js
│ │ ├── HotelDetails.js
│ │ ├── Login.js
│ │ ├── Login.module.scss
│ │ └── LoginTemp.js
│ │ ├── reportWebVitals.js
│ │ ├── setupTests.js
│ │ ├── store
│ │ ├── auth-context.js
│ │ ├── index.js
│ │ ├── travelervice-slice.js
│ │ └── travelservice-actions.js
│ │ └── util
│ │ ├── Constants.js
│ │ ├── RequireAuth.js
│ │ ├── UnAuthenticatedRoute.js
│ │ └── UtilFunctions.js
├── SpringBootApps
│ └── aws-utility-service
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── awsservice
│ │ │ │ ├── AwsUtilityServiceApplication.java
│ │ │ │ ├── UtitlityController.java
│ │ │ │ ├── config
│ │ │ │ └── DynamoDbEnhanced.java
│ │ │ │ └── model
│ │ │ │ ├── BookmarkedHotels.java
│ │ │ │ ├── HotelDetails.java
│ │ │ │ └── HotelDetailsConverter.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── awsservice
│ │ └── AwsUtilityServiceApplicationTests.java
├── TerraformAPIGatewayLambda
│ ├── .gitignore
│ ├── .terraform.lock.hcl
│ ├── LambdaFunctionsArchive
│ │ ├── DescriptionFn.zip
│ │ ├── FacilitiesFn.zip
│ │ ├── FavHotelsFn.zip
│ │ ├── HotelDataFn.zip
│ │ ├── LocationFn.zip
│ │ ├── PhotosFn.zip
│ │ ├── PostFavHotelsFn.zip
│ │ ├── ReviewsFn.zip
│ │ └── SearchFn.zip
│ ├── api_gateway.tf
│ ├── dynamodb.tf
│ ├── lambda_functions.tf
│ ├── lambda_functions_output.tf
│ ├── lambda_layers.tf
│ ├── layers
│ │ └── nodejs.zip
│ ├── locals.tf
│ ├── providers.tf
│ ├── random_resource.tf
│ ├── template
│ │ └── dynamodbpolicy.json
│ └── variables.tf
├── TerraformCognito
│ ├── .gitignore
│ ├── .terraform.lock.hcl
│ ├── README.md
│ ├── cognito.tf
│ ├── cognito_output.tf
│ ├── domain_r53.tf
│ ├── presignup_cognito.zip
│ ├── presignup_cognito
│ │ └── index.js
│ ├── presignup_lambda.tf
│ ├── providers.tf
│ └── variables.tf
├── TerraformECS
│ ├── .gitignore
│ ├── .terraform.lock.hcl
│ ├── README copy.md
│ ├── README.md
│ ├── alb.tf
│ ├── alb_output.tf
│ ├── ecs.tf
│ ├── ecs_output.tf
│ ├── ecs_roles.tf
│ ├── ecs_variables.tf
│ ├── locals.tf
│ ├── networking.tf
│ ├── networking_output.tf
│ ├── networking_variables.tf
│ ├── providers.tf
│ ├── r53_acm.tf
│ ├── r53_acm_output.tf
│ ├── security_group_output.tf
│ ├── security_groups.tf
│ ├── templates
│ │ └── s3-policy.json
│ └── variables.tf
├── TerraformEKS
│ ├── .gitignore
│ ├── .terraform.lock.hcl
│ ├── README.md
│ ├── dynamodb.tf
│ ├── dynamodb_output.tf
│ ├── eks-cluster.tf
│ ├── eks_output.tf
│ ├── helm_chart_config
│ │ └── monitoring_custom_values.yml
│ ├── iam-role.tf
│ ├── ingress.tf
│ ├── ingressalb.tf
│ ├── k8s_service_account.tf
│ ├── kube_prometheus_stack.tf
│ ├── kubernetes.tf
│ ├── locals.tf
│ ├── oidc_assume_role_policy.json
│ ├── security-groups.tf
│ ├── service_accounts
│ │ ├── main.tf
│ │ └── variables.tf
│ ├── variables.tf
│ ├── versions.tf
│ └── vpc.tf
└── TerraformS3DNS
│ ├── .gitignore
│ ├── .terraform.lock.hcl
│ ├── README.md
│ ├── cloudfront.tf
│ ├── locals.tf
│ ├── r53_acm_output.tf
│ ├── r53_acm_setup.tf
│ ├── s3.tf
│ ├── s3_output.tf
│ ├── templates
│ └── s3-policy.json
│ ├── variables.tf
│ └── versions.tf
├── Azure
├── AKSManifests
│ ├── azure-pipelines.yml
│ └── manifests
│ │ ├── Ingress.yml
│ │ ├── azureutilityservice.yml
│ │ ├── bookingservice.yml
│ │ └── cluster-issuer.yml
├── SpringBootApps
│ ├── azureutitlityservice
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ │ └── wrapper
│ │ │ │ ├── maven-wrapper.jar
│ │ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ ├── azureutilityservice
│ │ │ │ │ ├── AzureutitlityserviceApplication.java
│ │ │ │ │ ├── UtitlityController.java
│ │ │ │ │ └── repository
│ │ │ │ │ │ └── HotelRepository.java
│ │ │ │ │ └── azureutitlityservice
│ │ │ │ │ └── model
│ │ │ │ │ ├── BookmarkedHotels.java
│ │ │ │ │ └── HotelDetails.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── azureutilityservice
│ │ │ └── AzureutitlityserviceApplicationTests.java
│ └── hotelsearchserviceazure
│ │ ├── .gitignore
│ │ ├── .mvn
│ │ └── wrapper
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ │ ├── mvnw
│ │ ├── mvnw.cmd
│ │ ├── pom.xml
│ │ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── hotelsearchservice
│ │ │ │ ├── ExceptionHandler.java
│ │ │ │ ├── HotelBookingController.java
│ │ │ │ ├── HotelsearchserviceazureApplication.java
│ │ │ │ ├── dto
│ │ │ │ └── HotelSearchDto.java
│ │ │ │ ├── model
│ │ │ │ ├── hotels
│ │ │ │ │ ├── AllInclusiveAmount.java
│ │ │ │ │ ├── Badge.java
│ │ │ │ │ ├── Base.java
│ │ │ │ │ ├── Benefit.java
│ │ │ │ │ ├── Block.java
│ │ │ │ │ ├── BookingHome.java
│ │ │ │ │ ├── Bwallet.java
│ │ │ │ │ ├── Checkin.java
│ │ │ │ │ ├── Checkout.java
│ │ │ │ │ ├── CompositePriceBreakdown.java
│ │ │ │ │ ├── Credit.java
│ │ │ │ │ ├── DiscountedAmount.java
│ │ │ │ │ ├── Distance.java
│ │ │ │ │ ├── ExcludedAmount.java
│ │ │ │ │ ├── ExtraLinesDescription.java
│ │ │ │ │ ├── FavoriteHotel.java
│ │ │ │ │ ├── GrossAmount.java
│ │ │ │ │ ├── GrossAmountPerNight.java
│ │ │ │ │ ├── HotelDescription.java
│ │ │ │ │ ├── HotelFacitlites.java
│ │ │ │ │ ├── HotelPhotos.java
│ │ │ │ │ ├── HotelReview.java
│ │ │ │ │ ├── Hotels.java
│ │ │ │ │ ├── IncludedTaxesAndChargesAmount.java
│ │ │ │ │ ├── Item.java
│ │ │ │ │ ├── ItemAmount.java
│ │ │ │ │ ├── MapBoundingBox.java
│ │ │ │ │ ├── MlTag.java
│ │ │ │ │ ├── NetAmount.java
│ │ │ │ │ ├── PriceBreakdown.java
│ │ │ │ │ ├── ProductPriceBreakdown.java
│ │ │ │ │ ├── Result.java
│ │ │ │ │ ├── ReviewAuthor.java
│ │ │ │ │ ├── ReviewDetails.java
│ │ │ │ │ ├── ReviewPhoto.java
│ │ │ │ │ ├── ReviewerPhoto.java
│ │ │ │ │ ├── RewardAmount.java
│ │ │ │ │ ├── Rewards.java
│ │ │ │ │ ├── RoomDistribution.java
│ │ │ │ │ ├── Sort.java
│ │ │ │ │ ├── StayedRoomInfo.java
│ │ │ │ │ ├── StrikethroughAmount.java
│ │ │ │ │ ├── StrikethroughAmountPerNight.java
│ │ │ │ │ ├── SumCredits.java
│ │ │ │ │ ├── Tag.java
│ │ │ │ │ └── Total.java
│ │ │ │ └── location
│ │ │ │ │ ├── BMaxLosData.java
│ │ │ │ │ └── Location.java
│ │ │ │ ├── restservice
│ │ │ │ ├── AzureUtilityRestClient.java
│ │ │ │ ├── BookingApiRestClient.java
│ │ │ │ ├── FeignErrorDecoder.java
│ │ │ │ └── HotelBookingServiceFeignConfig.java
│ │ │ │ └── security
│ │ │ │ ├── AzureADB2CJwtAuthFilter.java
│ │ │ │ ├── AzureB2CIdTokenProcessor.java
│ │ │ │ ├── JwtAuthentication.java
│ │ │ │ ├── JwtConfiguration.java
│ │ │ │ ├── JwtIdTokenCredentialsHolder.java
│ │ │ │ └── SecurityConfiguration.java
│ │ └── resources
│ │ │ └── application.properties
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── hotelsearchservice
│ │ └── HotelsearchserviceazureApplicationTests.java
├── TerraformAKS
│ ├── .gitignore
│ ├── .terraform.lock.hcl
│ ├── README.md
│ ├── aks-roles.tf
│ ├── aks.tf
│ ├── aks_output.tf
│ ├── cert-manager.tf
│ ├── cosmosdb.tf
│ ├── cosmosdb_output.tf
│ ├── kubernetes-manifests.tf
│ ├── locals.tf
│ ├── network.tf
│ ├── providers.tf
│ ├── resourcegroup.tf
│ ├── templates
│ │ └── external_dns_values.yaml.tmpl
│ └── variables.tf
├── TerraformAzureAPIMFunctionApp
│ ├── .gitignore
│ ├── .terraform.lock.hcl
│ ├── apim.tf
│ ├── apim
│ │ ├── main.tf
│ │ ├── output.tf
│ │ └── variables.tf
│ ├── apim_custom_domain
│ │ ├── main.tf
│ │ ├── output.tf
│ │ └── variables.tf
│ ├── apim_insights.tf
│ ├── custom_domain.tf
│ ├── functioncode
│ │ └── Functions.zip
│ ├── lambda_functions.tf
│ ├── locals.tf
│ ├── output.tf
│ ├── provider.tf
│ ├── resource_group.tf
│ ├── storage_accounts.tf
│ └── variables.tf
├── TerraformCDN
│ ├── .gitignore
│ ├── .terraform.lock.hcl
│ ├── README.md
│ ├── customscript.ps1
│ ├── main.tf
│ ├── outputscript.ps1
│ ├── providers.tf
│ └── variables.tf
└── TravelPOCFrontend
│ ├── .gitignore
│ ├── README.md
│ ├── azure-pipelines.yml
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ ├── favicon.ico
│ ├── index.html
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── robots.txt
│ └── src
│ ├── App.js
│ ├── App.scss
│ ├── App.test.js
│ ├── components
│ ├── booking
│ │ └── BookingDetails.js
│ ├── hotel
│ │ ├── FavoriteHotels.js
│ │ ├── HotelDescription.js
│ │ ├── HotelFacilities.js
│ │ ├── HotelImages.js
│ │ ├── HotelList.js
│ │ ├── HotelReview.js
│ │ ├── HotelTopBar.js
│ │ ├── MainReview.js
│ │ └── SavedHotel.js
│ ├── search
│ │ ├── FlightSearch.js
│ │ ├── FlightSearchAutoSuggest.js
│ │ ├── HotelSearch.js
│ │ ├── SearchComponent.js
│ │ └── SearchComponent.module.scss
│ └── ui
│ │ ├── Layout.js
│ │ ├── Modal.js
│ │ ├── NavBar.js
│ │ ├── NavBar.module.scss
│ │ └── Themes.js
│ ├── hooks
│ └── use-http.js
│ ├── index.js
│ ├── index.scss
│ ├── logo.svg
│ ├── pages
│ ├── FavoriteHotels.js
│ ├── FlightBooking.js
│ ├── HotelBooking.js
│ ├── HotelDetails.js
│ ├── Login.js
│ └── Login.module.scss
│ ├── reportWebVitals.js
│ ├── setupTests.js
│ ├── store
│ ├── auth-context.js
│ ├── index.js
│ ├── travelervice-slice.js
│ └── travelservice-actions.js
│ └── util
│ ├── Constants.js
│ ├── RequireAuth.js
│ ├── UnAuthenticatedRoute.js
│ ├── UtilFunctions.js
│ └── authConfig.js
└── README.md
/AWS/EKSKubernetesManifests/AwsUtility.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ConfigMap
3 | metadata:
4 | name: aws-utitlity-service
5 | data:
6 | kubernetes.profile: "Y"
7 | ---
8 | apiVersion: apps/v1
9 | kind: Deployment
10 | metadata:
11 | name: aws-utility-service
12 | labels:
13 | app: aws-utility-service
14 | s1p: aws-utility
15 | spec:
16 | selector:
17 | matchLabels:
18 | app: aws-utility-service
19 | template:
20 | metadata:
21 | labels:
22 | app: aws-utility-service
23 | spec:
24 | serviceAccountName: hotelservice
25 | containers:
26 | - name: aws-utility-service
27 | image: pavithravasudevan/aws-utility-service:0.0.1-SNAPSHOT
28 | imagePullPolicy: Always
29 | resources:
30 | requests:
31 | cpu: "300m"
32 | memory: "512Mi"
33 | limits:
34 | cpu: "500m"
35 | memory: "1Gi"
36 | envFrom:
37 | - configMapRef:
38 | name: aws-utitlity-service
39 | ports:
40 | - containerPort: 8080
41 | ---
42 | apiVersion: v1
43 | kind: Service
44 | metadata:
45 | name: aws-utility-service
46 | labels:
47 | s1p: aws-utility
48 | annotations:
49 | alb.ingress.kubernetes.io/healthcheck-path: /actuator/health/readiness
50 | spec:
51 | type: ClusterIP
52 | selector:
53 | app: aws-utility-service
54 | ports:
55 | - port: 80
56 | targetPort: 8080
--------------------------------------------------------------------------------
/AWS/EKSKubernetesManifests/HotelService.yaml:
--------------------------------------------------------------------------------
1 |
2 | apiVersion: v1
3 | kind: ConfigMap
4 | metadata:
5 | name: hotel-service
6 | data:
7 | rapidapi.key: << Placeholder for rapid api key >>
8 | api.awsUtilityUrl: http://aws-utility-service:80/
9 | ---
10 | apiVersion: apps/v1
11 | kind: Deployment
12 | metadata:
13 | name: hotel-service
14 | labels:
15 | app: hotel-service
16 | s1p: hotel
17 | spec:
18 | replicas: 1
19 | selector:
20 | matchLabels:
21 | app: hotel-service
22 | template:
23 | metadata:
24 | labels:
25 | app: hotel-service
26 | spec:
27 | containers:
28 | - name: hotel-service
29 | image: pavithravasudevan/hotelsearchservice:0.0.1-SNAPSHOT
30 | imagePullPolicy: Always
31 | envFrom:
32 | - configMapRef:
33 | name: hotel-service
34 | resources:
35 | requests:
36 | cpu: "500m"
37 | memory: "512Mi"
38 | limits:
39 | cpu: "500m"
40 | memory: "1Gi"
41 | ports:
42 | - containerPort: 8102
43 | ---
44 | apiVersion: v1
45 | kind: Service
46 | metadata:
47 | name: hotel-service
48 | labels:
49 | s1p: hotel
50 | annotations:
51 | alb.ingress.kubernetes.io/healthcheck-path: /actuator/health/readiness
52 | spec:
53 | type: NodePort
54 | selector:
55 | app: hotel-service
56 | ports:
57 | - port: 80
58 | targetPort: 8102
--------------------------------------------------------------------------------
/AWS/EKSKubernetesManifests/external-dns.yaml:
--------------------------------------------------------------------------------
1 |
2 | apiVersion: rbac.authorization.k8s.io/v1beta1
3 | kind: ClusterRole
4 | metadata:
5 | name: external-dns
6 | rules:
7 | - apiGroups: [""]
8 | resources: ["services"]
9 | verbs: ["get","watch","list"]
10 | - apiGroups: [""]
11 | resources: ["pods"]
12 | verbs: ["get","watch","list"]
13 | - apiGroups: ["extensions"]
14 | resources: ["ingresses"]
15 | verbs: ["get","watch","list"]
16 | - apiGroups: [""]
17 | resources: ["nodes"]
18 | verbs: ["list"]
19 | ---
20 | apiVersion: rbac.authorization.k8s.io/v1beta1
21 | kind: ClusterRoleBinding
22 | metadata:
23 | name: external-dns-viewer
24 | roleRef:
25 | apiGroup: rbac.authorization.k8s.io
26 | kind: ClusterRole
27 | name: external-dns
28 | subjects:
29 | - kind: ServiceAccount
30 | name: external-dns
31 | namespace: default
32 | ---
33 | apiVersion: apps/v1
34 | kind: Deployment
35 | metadata:
36 | name: external-dns
37 | spec:
38 | selector:
39 | matchLabels:
40 | app: external-dns
41 | strategy:
42 | type: Recreate
43 | template:
44 | metadata:
45 | labels:
46 | app: external-dns
47 | spec:
48 | serviceAccountName: external-dns
49 | containers:
50 | - name: external-dns
51 | image: bitnami/external-dns:0.7.1
52 | args:
53 | - --source=service
54 | - --source=ingress
55 | - --domain-filter=pavithraavasudevan.com # will make ExternalDNS see only the hosted zones matching provided domain, omit to process all available hosted zones
56 | - --provider=aws
57 | - --policy=upsert-only # would prevent ExternalDNS from deleting any records, omit to enable full synchronization
58 | - --aws-zone-type=public # only look at public hosted zones (valid values are public, private or no value for both)
59 | - --registry=txt
60 | - --txt-owner-id=my-identifier
61 | ---
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/.github/workflows/node.js.yml:
--------------------------------------------------------------------------------
1 | # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3 |
4 | name: Node.js CI
5 |
6 | on:
7 | push:
8 | branches: [ main ]
9 | pull_request:
10 | branches: [ main ]
11 |
12 |
13 | jobs:
14 | build:
15 |
16 | runs-on: ubuntu-latest
17 | strategy:
18 | matrix:
19 | node-version: [14.x]
20 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21 |
22 | steps:
23 | - uses: actions/checkout@v2
24 | - name: Use Node.js ${{ matrix.node-version }}
25 | uses: actions/setup-node@v2
26 | with:
27 | node-version: ${{ matrix.node-version }}
28 | cache: 'npm'
29 | - run: npm install
30 | - run: echo ${GITHUB_WORKSPACE}
31 | - run: npm run build
32 | - name: Upload a Build Artifact
33 | uses: actions/upload-artifact@v2.3.1
34 | with:
35 | name: artifact
36 | path: /home/runner/work/HotelSearchServiceFrontEnd/HotelSearchServiceFrontEnd/build
37 |
38 | if-no-files-found: warn
39 | retention-days: 2
40 |
41 |
42 | deploy:
43 | name: Deploy to S3
44 | needs: build
45 | runs-on: ubuntu-latest
46 | steps:
47 | - name: Configure AWS Credentials
48 | uses: aws-actions/configure-aws-credentials@v1
49 | with:
50 | aws-access-key-id: ${{ secrets.aws_access_key_id }}
51 | aws-secret-access-key: ${{ secrets.aws_access_key_secret }}
52 | aws-region: us-east-1
53 | - name: Workspace value
54 | run: echo ${GITHUB_WORKSPACE}
55 | - name: show contents
56 | run: ls ${GITHUB_WORKSPACE}
57 | - name: Retrieve artifacts
58 | uses: actions/download-artifact@v2
59 | with:
60 | name: artifact
61 | path: /home/runner/work/HotelSearchServiceFrontEnd/HotelSearchServiceFrontEnd/build
62 |
63 | - name: Deploy static site to S3 bucket
64 | run: aws s3 sync ${GITHUB_WORKSPACE}/build s3://hotelsearch.pavithraavasudevan.com.d0e --delete
65 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13 |
14 | The page will reload when you make changes.\
15 | You may also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
31 |
32 |
33 |
34 | #### All values in src/Util/Constants.js need to be customized. Comments have been added accordingly
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bookingservicefrontend",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@emotion/react": "^11.7.0",
7 | "@emotion/styled": "^11.6.0",
8 | "@mui/icons-material": "^5.2.1",
9 | "@mui/lab": "^5.0.0-alpha.59",
10 | "@mui/material": "^5.2.2",
11 | "@mui/styled-engine-sc": "^5.1.0",
12 | "@reduxjs/toolkit": "^1.7.1",
13 | "@testing-library/jest-dom": "^5.16.1",
14 | "@testing-library/react": "^11.2.7",
15 | "@testing-library/user-event": "^12.8.3",
16 | "amazon-cognito-identity-js": "^5.2.4",
17 | "currency-symbol-map": "^5.0.1",
18 | "date-fns": "^2.27.0",
19 | "dateformat": "^5.0.2",
20 | "html-react-parser": "^1.4.4",
21 | "react": "^17.0.2",
22 | "react-dom": "^17.0.2",
23 | "react-redux": "^7.2.6",
24 | "react-router-dom": "^6.2.1",
25 | "react-scripts": "4.0.3",
26 | "react-slick": "^0.28.1",
27 | "slick-carousel": "^1.8.1",
28 | "styled-components": "^5.3.3",
29 | "web-vitals": "^1.1.2"
30 | },
31 | "scripts": {
32 | "start": "react-scripts start",
33 | "build": "CI=false && react-scripts build",
34 | "test": "react-scripts test",
35 | "eject": "react-scripts eject"
36 | },
37 | "eslintConfig": {
38 | "extends": [
39 | "react-app",
40 | "react-app/jest"
41 | ]
42 | },
43 | "browserslist": {
44 | "production": [
45 | ">0.2%",
46 | "not dead",
47 | "not op_mini all"
48 | ],
49 | "development": [
50 | "last 1 chrome version",
51 | "last 1 firefox version",
52 | "last 1 safari version"
53 | ]
54 | },
55 | "devDependencies": {
56 | "sass": "^1.44.0",
57 | "sass-loader": "^12.4.0"
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/HotelSearchServiceFrontEnd/public/favicon.ico
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
19 |
20 |
29 | React App
30 |
31 |
32 |
33 |
34 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/HotelSearchServiceFrontEnd/public/logo192.png
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/HotelSearchServiceFrontEnd/public/logo512.png
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/App.js:
--------------------------------------------------------------------------------
1 |
2 | import './App.scss';
3 | import Layout from './components/ui/Layout';
4 | import FlightBooking from './pages/FlightBooking';
5 | import HotelBooking from './pages/HotelBooking';
6 | import HotelDetails from './pages/HotelDetails';
7 | import { Route, Routes, Navigate, Link } from 'react-router-dom';
8 | import FavoriteHotels from './components/hotel/FavoriteHotels';
9 | import RequireAuth from './util/RequireAuth';
10 |
11 |
12 |
13 | Number.prototype.format = function(n, x) {
14 | var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\.' : '$') + ')';
15 | return this.toFixed(Math.max(0, ~~n)).replace(new RegExp(re, 'g'), '$&,');
16 | };
17 |
18 | function App() {
19 |
20 | return (
21 |
22 |
23 |
24 |
25 |
26 | } />
27 | }/>
28 | } />
29 | } />
30 | }>
31 |
32 | } />
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | );
42 | }
43 |
44 | export default App;
45 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/components/hotel/HotelDescription.js:
--------------------------------------------------------------------------------
1 |
2 | import React,{useEffect,useContext,useState, useCallback} from 'react';
3 | import { NormalParagraph } from '../ui/Themes';
4 | import AuthContext from '../../store/auth-context';
5 | import { HOTEL_SERVICE_URL } from '../../util/Constants';
6 |
7 | const HotelDescription =(props)=>{
8 | const authCtx = useContext(AuthContext);
9 | const [hotelDescription,setHotelDescription]=useState(null);
10 | const getHotelDescription=useCallback(async()=>{
11 | const response = await fetch(HOTEL_SERVICE_URL+'HotelDescription?locale=en-gb&hotelId='+props.hotelId, authCtx.reqHeader);
12 | if (!response.ok) {
13 | // alert('Could not fetch details!');
14 | setHotelDescription();
15 |
16 | }
17 | const description = await response.json();
18 | setHotelDescription(description);
19 |
20 |
21 | }, [props.hotelId]);
22 | useEffect(()=>{
23 | getHotelDescription();
24 | }, [getHotelDescription]);
25 |
26 |
27 | return
28 | {hotelDescription &&
29 | {hotelDescription.description}
30 | {hotelDescription.extra_lines && hotelDescription.extra_lines.imp_info}
31 | }
32 |
33 |
34 | }
35 |
36 | export default HotelDescription;
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/components/hotel/HotelReview.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ResultDiv } from '../ui/Themes';
3 | import { Grid, Typography } from '@mui/material';
4 |
5 |
6 | const HotelReviews = (props)=>{
7 |
8 | return props.reviews.map(review=>{ return (
9 |
10 |
11 |
12 |
13 | {review.title}
14 |
15 |
16 | {review.author.name} reviewed this on {review.date}
17 |
18 |
19 |
20 |
21 | Pros: {review.pros}
22 |
23 |
24 | Cons: {review.cons}
25 |
26 |
27 | {props.showMoreReviews &&
28 | View More Reviews
29 | }
30 |
31 |
32 |
33 | )
34 | })
35 |
36 | }
37 |
38 | export default HotelReviews;
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/components/hotel/HotelTopBar.js:
--------------------------------------------------------------------------------
1 | import React, { useContext, useEffect, useState } from 'react';
2 | import { useTheme } from '@mui/material/styles';
3 | import Box from '@mui/material/Box';
4 |
5 | import Typography from '@mui/material/Typography';
6 |
7 | import CardContent from '@mui/material/CardContent';
8 |
9 | import { styled } from '@mui/material/styles';
10 | import { StyledCard } from '../ui/Themes';
11 |
12 | import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder';
13 | import FavoriteIcon from '@mui/icons-material/Favorite';
14 | import { pink } from '@mui/material/colors';
15 | import AuthContext from '../../store/auth-context';
16 | import { useDispatch, useSelector } from 'react-redux';
17 | import { postBookmarkHotel } from '../../store/travelservice-actions';
18 |
19 | const HotelTopBar = (props) => {
20 | const dispatch = useDispatch();
21 | const bookmarkedProps = useSelector((state) => state.travelService.bookmarkedProperties);
22 | const authCtx=useContext(AuthContext);
23 | const [isFavorite,setFavorite]=useState(false);
24 | useEffect(()=>{
25 |
26 | const elem=bookmarkedProps.hotelsList.find(x=>x.hotelId===props.hotelId);
27 | if(elem!==undefined)
28 | setFavorite(true);
29 |
30 | },[])
31 |
32 | const addToFavHandler = ()=>{
33 | if(authCtx.isLoggedIn){
34 |
35 | if (authCtx.reqHeader !== null && authCtx.reqHeader !== undefined) {
36 |
37 | dispatch(postBookmarkHotel(authCtx.reqHeader, authCtx.userName,props.hotelId));
38 | }
39 | }else{
40 | alert('Please login');
41 | }
42 |
43 | }
44 | return (
45 |
46 |
47 |
48 | {props.name}
49 |
50 |
51 |
52 |
53 | {isFavorite?:}
54 |
55 | );
56 | }
57 |
58 | export default HotelTopBar;
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/components/hotel/MainReview.js:
--------------------------------------------------------------------------------
1 | import React,{useEffect,useContext,useState, Fragment,useCallback} from 'react';
2 | import AuthContext from '../../store/auth-context';
3 | import { HOTEL_SERVICE_URL } from '../../util/Constants';
4 | import Modal from '../ui/Modal';
5 | import HotelReviews from './HotelReview';
6 | import { checkArray,delay } from '../../util/UtilFunctions';
7 |
8 | const MainReview = (props)=>{
9 | const authCtx=useContext(AuthContext);
10 | const [showMoreReviews, setShowMoreReviews] = useState(false);
11 | const [reviews,setReviews]=useState();
12 | const showDialog = useCallback(() => setShowMoreReviews(true));
13 | const hideDialog = useCallback(() => setShowMoreReviews(false));
14 | const fetchHotelReviews=useCallback(async ()=>{
15 |
16 | delay(2000);
17 | const response = await fetch(HOTEL_SERVICE_URL + 'HotelReviews?locale=en-gb&hotelId=' + props.hotelId, authCtx.reqHeader);
18 | if (!response.ok) {
19 | // alert('Could not fetch details!');
20 | setReviews([]);
21 |
22 | }
23 | const reviewList = await response.json();
24 | setReviews(reviewList);
25 | },[props.hotelId,authCtx]);
26 |
27 | useEffect(() => {
28 | //rapid api throws error for more that 3 requests in a second.. so adding delay here
29 | fetchHotelReviews();
30 |
31 | }, [fetchHotelReviews]);
32 | let details ='';
33 | if(reviews && checkArray(reviews.result)){
34 | details = <>
35 |
36 |
37 |
38 |
39 | >
40 | }
41 | return
42 |
43 |
44 | {details}
45 |
46 |
47 |
48 | }
49 |
50 | export default MainReview;
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/components/search/SearchComponent.module.scss:
--------------------------------------------------------------------------------
1 | .inputSpacing{
2 | margin-right: 10px!important;
3 | margin-left: 15px!important;
4 | margin-top: 2px!important;
5 | color: white!important;
6 | }
7 |
8 | .largeInput{
9 | margin-right: 15px!important;
10 | }
11 |
12 | .searchMainDiv{
13 | background: #ebf3ff;
14 | border-color: #a3d7fc;
15 | box-shadow: 0 0 8px #a3d7fc;
16 | }
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/components/ui/Layout.js:
--------------------------------------------------------------------------------
1 | import React,{useState} from 'react';
2 |
3 | import { ThemeProvider as MuiThemeProvider} from '@mui/material/styles';
4 | import {darkTheme} from './Themes';
5 | import NavBar from './NavBar';
6 |
7 |
8 | const Layout =(props)=>{
9 |
10 | return (
11 |
12 |
13 |
14 | {props.children}
15 |
16 |
17 | );
18 | }
19 | export default Layout;
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/components/ui/Modal.js:
--------------------------------------------------------------------------------
1 | import Dialog from '@mui/material/Dialog';
2 | import DialogActions from '@mui/material/DialogActions';
3 | import DialogContent from '@mui/material/DialogContent';
4 | import DialogContentText from '@mui/material/DialogContentText';
5 | import DialogTitle from '@mui/material/DialogTitle';
6 | import useMediaQuery from '@mui/material/useMediaQuery';
7 | import { useTheme } from '@mui/material/styles';
8 | import Button from '@mui/material/Button';
9 | import { styled } from '@mui/material/styles';
10 | const Modal = (props)=>{
11 | const theme = useTheme();
12 | const fullScreen = useMediaQuery(theme.breakpoints.down('md'));
13 |
14 | const DarkDialog = styled(Dialog)(({ theme }) => ({
15 | backgroundColor: "transparent"
16 | }));
17 |
18 | return
24 |
25 | {props.title}
26 |
27 |
28 |
29 | {props.children}
30 |
31 |
32 |
33 |
36 |
37 |
38 |
39 | }
40 |
41 | export default Modal;
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/components/ui/NavBar.module.scss:
--------------------------------------------------------------------------------
1 | .root{
2 | background: linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%);
3 | border: 0;
4 | border-radius: 3;
5 | box-shadow: 0 3px 5px 2px rgba(255, 105, 135, .3);
6 | color: white;
7 | height: 48;
8 | font-size: 12px;
9 | padding: 0 30px;
10 |
11 | }
12 |
13 | .rightAlignment{
14 | float:right;
15 | margin-left: auto;
16 | margin-right: 0;
17 |
18 | }
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/hooks/use-http.js:
--------------------------------------------------------------------------------
1 | import { useReducer, useCallback } from 'react';
2 |
3 | function httpReducer(state, action) {
4 | if (action.type === 'SEND') {
5 | return {
6 | data: null,
7 | error: null,
8 | status: 'pending',
9 | };
10 | }
11 |
12 | if (action.type === 'SUCCESS') {
13 | return {
14 | data: action.responseData,
15 | error: null,
16 | status: 'completed',
17 | };
18 | }
19 |
20 | if (action.type === 'ERROR') {
21 | return {
22 | data: null,
23 | error: action.errorMessage,
24 | status: 'completed',
25 | };
26 | }
27 |
28 | return state;
29 | }
30 |
31 | function useHttp(requestFunction, startWithPending = false) {
32 | const [httpState, dispatch] = useReducer(httpReducer, {
33 | status: startWithPending ? 'pending' : null,
34 | data: null,
35 | error: null,
36 | });
37 |
38 | const sendRequest = useCallback(
39 | async function (requestData) {
40 | dispatch({ type: 'SEND' });
41 | try {
42 | const responseData = await requestFunction(requestData);
43 | dispatch({ type: 'SUCCESS', responseData });
44 | } catch (error) {
45 | dispatch({
46 | type: 'ERROR',
47 | errorMessage: error.message || 'Something went wrong!',
48 | });
49 | }
50 | },
51 | [requestFunction]
52 | );
53 |
54 | return {
55 | sendRequest,
56 | ...httpState,
57 | };
58 | }
59 |
60 | export default useHttp;
61 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.scss';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 | import { BrowserRouter } from 'react-router-dom';
7 | import { Provider } from 'react-redux';
8 | import { AuthContextProvider } from './store/auth-context';
9 | import store from './store/index';
10 |
11 | ReactDOM.render(
12 |
13 |
14 |
15 | ,
16 | document.getElementById('root')
17 | );
18 |
19 | // If you want to start measuring performance in your app, pass a function
20 | // to log results (for example: reportWebVitals(console.log))
21 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
22 | reportWebVitals();
23 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/index.scss:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/pages/FavoriteHotels.js:
--------------------------------------------------------------------------------
1 | import SavedHotel from "../components/hotel/SavedHotel"
2 |
3 | const FavoriteHotels = ()=>{
4 | return
5 | }
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/pages/HotelDetails.js:
--------------------------------------------------------------------------------
1 |
2 | import React, { useEffect } from 'react';
3 | import Box from '@mui/material/Box';
4 | import Grid from '@mui/material/Grid';
5 |
6 | import HotelTopBar from '../components/hotel/HotelTopBar';
7 | import ImgSlider from '../components/hotel/HotelImages';
8 | import HotelDescription from '../components/hotel/HotelDescription';
9 |
10 | import HotelFacilites from '../components/hotel/HotelFacilities';
11 | import { useParams } from 'react-router-dom';
12 | import MainReview from '../components/hotel/MainReview';
13 | const HotelDetails = () => {
14 | const params = useParams();
15 |
16 |
17 | const { hotelId,hotelName } = params;
18 |
19 | useEffect(() => {
20 | window.scrollTo({
21 | top: 0,
22 | behavior: "smooth"
23 | });
24 |
25 |
26 | }, []);
27 |
28 |
29 | return
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | }
52 |
53 | export default HotelDetails;
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/pages/Login.module.scss:
--------------------------------------------------------------------------------
1 | .login {
2 |
3 | max-width: 40rem;
4 | margin: 2rem auto;
5 | padding: 20px;
6 | box-shadow:0 8px 16px 2px rgba(200, 198, 207, 0.2);
7 | height: calc(100% - 122px);
8 | width:90%;
9 | background-color: #050b24;
10 | }
11 |
12 | .actions {
13 | text-align: center;
14 | margin-top:20px;
15 | }
16 | .floatRight{
17 | margin-left: auto;
18 | margin-right: 0;
19 | float:right;
20 |
21 | }
22 | .btnActions {
23 | margin-top: 1.5rem;
24 | display: flex;
25 | flex-direction: column;
26 | align-items: center;
27 | }
28 | .borderBottom{
29 | padding:10px;
30 | margin-bottom: 20px;
31 | border-bottom: 1px solid;
32 | }
33 | .cfInputField {
34 | appearance: none;
35 | background-color: #202028;
36 | border-radius: 4px;
37 | border: 2px solid #383846;
38 | box-sizing: border-box;
39 | color: #bec2cc;
40 | font-family: 'Rubik', Helvetica, Arial, Tahoma, Verdana, sans-serif;
41 | font-weight: 500;
42 | outline: none;
43 | position: relative;
44 | transition: background-color 0.25s ease, border-color 0.25s ease,
45 | color 0.25s ease, box-shadow 0.25s ease, color 0.25s ease;
46 | width: 100%;
47 | z-index: 1;
48 |
49 | &:hover {
50 | background-color: #202028;
51 | border-color: mix(#383846, #00a3ff, 50%);
52 | color: #d4d7dd;
53 | }
54 |
55 | &:focus {
56 | background-color: #202028;
57 | border-color: #00a3ff;
58 | box-shadow: 0 0 6px 0 #00a3ff;
59 | color: #ffffff;
60 | }
61 |
62 | &::-webkit-input-placeholder {
63 | color: #757888;
64 | font-style: italic;
65 | font-weight: 500 !important;
66 | }
67 | &::-moz-placeholder {
68 | color: #757888;
69 | font-style: italic;
70 | font-weight: 500 !important;
71 | }
72 | &:-ms-input-placeholder {
73 | color: #757888;
74 | font-style: italic;
75 | font-weight: 500 !important;
76 | }
77 | &:-moz-placeholder {
78 | color: #757888;
79 | font-style: italic;
80 | font-weight: 500 !important;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/pages/LoginTemp.js:
--------------------------------------------------------------------------------
1 | import React,{useState} from 'react';
2 |
3 | const LoginTemp = ()=>{
4 |
5 | }
6 |
7 | export default LoginTemp;
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/store/index.js:
--------------------------------------------------------------------------------
1 | import {
2 | configureStore,
3 | combineReducers
4 |
5 | } from '@reduxjs/toolkit';
6 |
7 |
8 | import travelServiceSlice from './travelervice-slice';
9 |
10 | const combinedReducer = combineReducers({
11 | travelService: travelServiceSlice.reducer
12 | });
13 |
14 | const rootReducer = (state, action) => {
15 | if (action.type === 'logout') {
16 | state = undefined;
17 | }
18 | return combinedReducer(state, action);
19 | };
20 | const store = configureStore({
21 | reducer: rootReducer
22 |
23 | });
24 |
25 | /*const store = configureStore({
26 | reducer: { stockService:stockServiceSlice.reducer },
27 | });*/
28 |
29 | export default store;
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/store/travelervice-slice.js:
--------------------------------------------------------------------------------
1 | import { createSlice } from '@reduxjs/toolkit';
2 |
3 | const searchCriteria ={id:'',labelVal:'',fromDate:'',toDate:''};
4 |
5 |
6 | const travelServiceSlice = createSlice({
7 | name: 'travelService',
8 | initialState: { bookmarkedProperties: {},hotelsList:{},topFlightsList:{},searchedFlightsList:{},progress:false,hotelSearchCriteria:searchCriteria},
9 | reducers: {
10 | setBookmarkedProperties(state,action) {
11 | state.bookmarkedProperties = action.payload.bookmarkedProperties;
12 |
13 | },
14 | setHotelsList(state,action){
15 | state.hotelsList=action.payload.hotelsList;
16 | },
17 | setTopFlightsList(state,action){
18 | state.topFlightsList=action.payload.topFlightsList;
19 |
20 | },
21 | setSearchedFlightsList(state,action){
22 | state.searchedFlightsList=action.payload.searchedFlightsList
23 | },
24 |
25 | setProgress(state,action){
26 | state.progress=action.payload.progress;
27 | },
28 | setHotelSearchCritera(state,action){
29 | state.hotelSearchCriteria=action.payload.criteria;
30 | },
31 | logout: state => {
32 |
33 | state.bookmarkedProperties ={};
34 | state.hotelsList={};
35 | state.progress={};
36 | state.searchedFlightsList={};
37 | state.topFlightsList={};
38 | state.searchedFlightsList={};
39 |
40 | }
41 |
42 | },
43 | });
44 |
45 | export const travelServiceActions = travelServiceSlice.actions;
46 |
47 | export default travelServiceSlice;
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/util/Constants.js:
--------------------------------------------------------------------------------
1 | export const SERVICE_API_URL = 'http://localhost:8102/';
2 | export const REVERSE_GEO_API='https://api.bigdatacloud.net/data/reverse-geocode-client?latitude=37.42159&longitude=-122.0837&localityLanguage=en'
3 | ////Key has to be added https://www.bigdatacloud.com/
4 | export const LOCATION_API='https://api.bigdatacloud.net/data/ip-geolocation?key=b45faf7c8e6b4cd2b94a4b490dd2f3e5'
5 |
6 | //Backend Service URL
7 | export const TRAVEL_SERVICE_API_URL = 'https://bookingserviceapi.pavithraavasudevan.com/';
8 | export const HOTEL_SERVICE_URL=TRAVEL_SERVICE_API_URL;
9 | export const FLIGHT_SERVICE_URL=TRAVEL_SERVICE_API_URL+'flight-service/'
10 | export const IATA_SERVICE_URL=TRAVEL_SERVICE_API_URL+'iata-service/'
11 | // Cognito URL . Custom Domain is used. Redirect URL should match with Client App Settings
12 | export const COGNITO_URL='https://newauth.pavithraavasudevan.com/login?client_id=vp5414n8rqqsdbsrg9o17pgof&response_type=token&scope=aws.cognito.signin.user.admin+email+openid+profile&redirect_uri=http://localhost:3000/';
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/util/RequireAuth.js:
--------------------------------------------------------------------------------
1 | import { Navigate ,useLocation,Outlet} from 'react-router-dom';
2 | import {useContext} from 'react';
3 | import AuthContext from '../store/auth-context';
4 | function RequireAuth({ children, redirectTo }) {
5 | const ctx = useContext(AuthContext);
6 | let isAuthenticated = ctx.isLoggedIn;
7 | let location = useLocation();
8 |
9 |
10 | if (!isAuthenticated) {
11 | // Redirect them to the /login page, but save the current location they were
12 | // trying to go to when they were redirected. This allows us to send them
13 | // along to that page after they login, which is a nicer user experience
14 | // than dropping them off on the home page.
15 | return ;
16 | }
17 |
18 | return ;
19 | }
20 |
21 | export default RequireAuth;
22 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/util/UnAuthenticatedRoute.js:
--------------------------------------------------------------------------------
1 | import { Route, Redirect } from 'react-router-dom';
2 | export default ({ component: C, appProps, ...rest }) =>
3 |
6 | !appProps
7 | ?
8 | : }
9 | />;
10 |
--------------------------------------------------------------------------------
/AWS/HotelSearchServiceFrontEnd/src/util/UtilFunctions.js:
--------------------------------------------------------------------------------
1 |
2 | export const checkArray=(element)=>{
3 | if(element && Array.isArray(element) && element.length)
4 | return true;
5 | return false;
6 | }
7 |
8 | export const delay = ms => new Promise(res => setTimeout(res, ms));
--------------------------------------------------------------------------------
/AWS/SpringBootApps/aws-utility-service/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/AWS/SpringBootApps/aws-utility-service/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/SpringBootApps/aws-utility-service/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/AWS/SpringBootApps/aws-utility-service/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/AWS/SpringBootApps/aws-utility-service/src/main/java/com/awsservice/AwsUtilityServiceApplication.java:
--------------------------------------------------------------------------------
1 | package com.awsservice;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.context.annotation.Bean;
6 | import org.springframework.web.servlet.config.annotation.CorsRegistry;
7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
8 |
9 | @SpringBootApplication
10 | public class AwsUtilityServiceApplication {
11 |
12 | public static void main(String[] args) {
13 | SpringApplication.run(AwsUtilityServiceApplication.class, args);
14 | }
15 | @Bean
16 | public WebMvcConfigurer corsConfigurer() {
17 | return new WebMvcConfigurer() {
18 | @Override
19 | public void addCorsMappings(CorsRegistry registry) {
20 | registry.addMapping("/**").allowedOrigins("*").allowedMethods("*").allowedHeaders("*");
21 | }
22 | };
23 | }
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/AWS/SpringBootApps/aws-utility-service/src/main/java/com/awsservice/model/BookmarkedHotels.java:
--------------------------------------------------------------------------------
1 | package com.awsservice.model;
2 |
3 | import java.util.List;
4 |
5 |
6 |
7 | import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean;
8 | import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbPartitionKey;
9 |
10 | @DynamoDbBean
11 | public class BookmarkedHotels {
12 |
13 | @DynamoDbPartitionKey
14 | public String getUsername() {
15 | return username;
16 | }
17 |
18 | public void setUsername(String username) {
19 | this.username = username;
20 | }
21 |
22 | private String username;
23 |
24 | private List hotelsList;
25 |
26 |
27 |
28 | public List getHotelsList() {
29 | return hotelsList;
30 | }
31 |
32 | public void setHotelsList(List hotelsList) {
33 | this.hotelsList = hotelsList;
34 | }
35 |
36 | public BookmarkedHotels()
37 | {
38 | }
39 |
40 |
41 | }
--------------------------------------------------------------------------------
/AWS/SpringBootApps/aws-utility-service/src/main/java/com/awsservice/model/HotelDetails.java:
--------------------------------------------------------------------------------
1 | package com.awsservice.model;
2 |
3 | import java.io.Serializable;
4 |
5 |
6 |
7 | import lombok.Data;
8 | import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean;
9 |
10 | @Data
11 | @DynamoDbBean
12 | public class HotelDetails implements Serializable{
13 | private String maxPhotoUrl;
14 | private String hotelName;
15 | private String cityName;
16 | private String country;
17 | private String distance;
18 | private String review;
19 | private double price;
20 | private int hotelId;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/AWS/SpringBootApps/aws-utility-service/src/main/java/com/awsservice/model/HotelDetailsConverter.java:
--------------------------------------------------------------------------------
1 | package com.awsservice.model;
2 |
3 | import java.io.IOException;
4 | import java.util.List;
5 |
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 |
9 | import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTypeConverter;
10 | import com.awsservice.UtitlityController;
11 | import com.fasterxml.jackson.core.JsonParseException;
12 | import com.fasterxml.jackson.core.JsonProcessingException;
13 | import com.fasterxml.jackson.core.type.TypeReference;
14 | import com.fasterxml.jackson.databind.JsonMappingException;
15 | import com.fasterxml.jackson.databind.ObjectMapper;
16 |
17 | public class HotelDetailsConverter implements DynamoDBTypeConverter> {
18 |
19 | private Logger logger = LoggerFactory.getLogger(HotelDetailsConverter.class);
20 | @Override
21 | public String convert(List objects) {
22 |
23 | ObjectMapper objectMapper = new ObjectMapper();
24 | try {
25 | String objectsString = objectMapper.writeValueAsString(objects);
26 |
27 | return objectsString;
28 | } catch (JsonProcessingException e) {
29 | logger.error(e.getMessage());
30 | }
31 | return null;
32 | }
33 |
34 | @Override
35 | public List unconvert(String jsonString) {
36 | ObjectMapper objectMapper = new ObjectMapper();
37 | try {
38 | List hotelDetailsList = objectMapper.readValue(jsonString, new TypeReference>(){});
39 | return hotelDetailsList;
40 | } catch (JsonParseException e) {
41 | logger.error(e.getMessage());
42 |
43 | } catch (JsonMappingException e) {
44 | logger.error(e.getMessage());
45 | } catch (IOException e) {
46 | logger.error(e.getMessage());
47 | }
48 | return null;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/AWS/SpringBootApps/aws-utility-service/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 |
2 | amazon.dynamodb.endpoint=https://dynamodb.us-east-1.amazonaws.com/
3 | amazon.dynamodb.region=us-east-1
4 | kubernetes.profile=N
5 | server.port=8080
6 | spring.application.name=aws-utility-service
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AWS/SpringBootApps/aws-utility-service/src/test/java/com/awsservice/AwsUtilityServiceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.awsservice;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class AwsUtilityServiceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/.gitignore:
--------------------------------------------------------------------------------
1 | # Local .terraform directories
2 | **/.terraform/*
3 |
4 | # .tfstate files
5 | *.tfstate
6 | *.tfstate.*
7 |
8 | # Crash log files
9 | crash.log
10 |
11 | *.tfvars
12 | .terraform
13 | *.pem
14 | *.ppk
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/DescriptionFn.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/DescriptionFn.zip
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/FacilitiesFn.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/FacilitiesFn.zip
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/FavHotelsFn.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/FavHotelsFn.zip
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/HotelDataFn.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/HotelDataFn.zip
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/LocationFn.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/LocationFn.zip
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/PhotosFn.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/PhotosFn.zip
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/PostFavHotelsFn.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/PostFavHotelsFn.zip
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/ReviewsFn.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/ReviewsFn.zip
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/SearchFn.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/TerraformAPIGatewayLambda/LambdaFunctionsArchive/SearchFn.zip
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/dynamodb.tf:
--------------------------------------------------------------------------------
1 | module "dynamodb_table" {
2 | source = "terraform-aws-modules/dynamodb-table/aws"
3 | name = local.dynamodb_table_name
4 | hash_key = "username"
5 |
6 | attributes = [
7 | {
8 | name = "username"
9 | type = "S"
10 | }
11 | ]
12 |
13 |
14 | }
15 |
16 | output "dynamo_arn"{
17 | value = module.dynamodb_table.dynamodb_table_arn
18 | }
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/lambda_functions_output.tf:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/lambda_layers.tf:
--------------------------------------------------------------------------------
1 | module "lambda_layer_with_package_deploying_externally" {
2 | source = "terraform-aws-modules/lambda/aws"
3 |
4 | create_layer = true
5 |
6 | layer_name = "${random_pet.this.id}-layer-local"
7 | description = "My amazing lambda layer (deployed from local)"
8 | compatible_runtimes = ["nodejs14.x"]
9 |
10 | create_package = false
11 | local_existing_package = "${path.module}/layers/nodejs.zip"
12 |
13 | ignore_source_code_hash = true
14 | }
15 |
16 | output "lambda_layer_arn" {
17 | value = module.lambda_layer_with_package_deploying_externally.lambda_layer_arn
18 |
19 | }
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/layers/nodejs.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/TerraformAPIGatewayLambda/layers/nodejs.zip
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/locals.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | dynamodb_table_name = "BookmarkedHotels"
3 | lambda_list = [
4 | {
5 |
6 | function_name = "Hotel_Location"
7 | file_name = "LocationFn"
8 | route = "/HotelLocations"
9 | method = "GET"
10 | dynamodbAccess =false
11 |
12 | },
13 | {
14 | function_name = "Hotel_Search"
15 | file_name = "SearchFn"
16 | route = "/Hotels"
17 | method = "GET"
18 | dynamodbAccess =false
19 | },
20 | {
21 | function_name = "Hotel_Description"
22 | file_name = "DescriptionFn"
23 | route = "/HotelDescription"
24 | method = "GET"
25 | dynamodbAccess =false
26 | },
27 | {
28 | function_name = "Hotel_Facilties"
29 | file_name = "FacilitiesFn"
30 | route = "/HotelFacilities"
31 | method = "GET"
32 | dynamodbAccess =false
33 | },
34 | {
35 | function_name = "Hotel_Reviews"
36 | file_name = "ReviewsFn"
37 | route = "/HotelReviews"
38 | method = "GET"
39 | dynamodbAccess =false
40 | },
41 | {
42 | function_name = "Hotel_Data"
43 | file_name = "HotelDataFn"
44 | route = "/HotelData"
45 | method = "GET"
46 | dynamodbAccess =false
47 | },
48 | {
49 | function_name = "Hotel_Photos"
50 | file_name = "PhotosFn"
51 | route = "/HotelPhotos"
52 | method = "GET"
53 | dynamodbAccess =false
54 | }]
55 | authenticated_lambda_list = [{
56 |
57 | function_name = "Fav_Hotels"
58 | file_name = "FavHotelsFn"
59 | route = "/FavoriteHotels"
60 | method = "GET"
61 | dynamodbAccess =true
62 |
63 | },
64 | {
65 | function_name = "Fav_Hotels_Post"
66 | file_name = "PostFavHotelsFn"
67 | route = "/FavoriteHotels"
68 | method = "POST"
69 | dynamodbAccess =true
70 | }]
71 |
72 | combined_lambdas_list=flatten([local.lambda_list,local.authenticated_lambda_list])
73 | }
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/providers.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_providers {
3 | aws = {
4 | source = "hashicorp/aws"
5 |
6 | }
7 | random = {
8 | source = "hashicorp/random"
9 |
10 | }
11 | archive = {
12 | source = "hashicorp/archive"
13 |
14 | }
15 | }
16 |
17 |
18 | }
19 |
20 | provider "aws" {
21 | region = var.aws_region
22 | }
23 |
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/random_resource.tf:
--------------------------------------------------------------------------------
1 | resource "random_pet" "this" {
2 | length = 2
3 | }
4 |
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/template/dynamodbpolicy.json:
--------------------------------------------------------------------------------
1 | {
2 | "Version": "2012-10-17",
3 | "Statement":[{
4 | "Effect": "Allow",
5 | "Action": [
6 | "dynamodb:BatchGetItem",
7 | "dynamodb:GetItem",
8 | "dynamodb:Query",
9 | "dynamodb:Scan",
10 | "dynamodb:BatchWriteItem",
11 | "dynamodb:PutItem",
12 | "dynamodb:UpdateItem"
13 | ],
14 | "Resource": "${dynamodb_table_name}"
15 | }
16 | ]
17 | }
--------------------------------------------------------------------------------
/AWS/TerraformAPIGatewayLambda/variables.tf:
--------------------------------------------------------------------------------
1 | variable "prefix" {
2 | default = "bookingserviceapi"
3 | }
4 |
5 | variable "aws_region" {
6 | default = "us-east-1"
7 | }
8 |
9 | variable "domain_name" {
10 | default = "pavithraavasudevan.com"
11 |
12 | }
13 |
14 |
15 | variable "cognito_endpoint" {
16 | default = "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_54VRcxXzc"
17 | }
18 |
19 | variable "cognito_client_id" {
20 | default = "vp5414n8rqqsdbsrg9o17pgof"
21 | }
22 |
23 | variable "rapidapi_key"{
24 |
25 | }
--------------------------------------------------------------------------------
/AWS/TerraformCognito/.gitignore:
--------------------------------------------------------------------------------
1 | # Local .terraform directories
2 | **/.terraform/*
3 |
4 | # .tfstate files
5 | *.tfstate
6 | *.tfstate.*
7 |
8 | # Crash log files
9 | crash.log
10 |
11 | *.tfvars
12 | .terraform
13 | *.pem
14 | *.ppk
--------------------------------------------------------------------------------
/AWS/TerraformCognito/README.md:
--------------------------------------------------------------------------------
1 | Create terraform.tfvars with the following entries:
2 |
3 | custom_domain_name = Registered Domain Name
4 |
5 | certificate_arn = ACM Certificate ARN
6 |
7 | Refer this article on setting up Google as IDP and configure the following values: https://aws.amazon.com/premiumsupport/knowledge-center/cognito-google-social-identity-provider/
8 |
9 | google_client_id
10 |
11 | google_client_secret
12 |
13 | redirect_url
14 |
15 | callback_url
16 |
17 | logout_url
--------------------------------------------------------------------------------
/AWS/TerraformCognito/cognito_output.tf:
--------------------------------------------------------------------------------
1 | output "client_pool_id"{
2 | description = "User Pool Id to be copied for authentication"
3 | value=module.aws_cognito_user_pool_complete_example.id
4 | }
5 |
6 | output "client_endpoint"{
7 |
8 | value=module.aws_cognito_user_pool_complete_example.endpoint
9 | }
10 | output "client_id" {
11 | value = module.aws_cognito_user_pool_complete_example.client_ids
12 |
13 | }
--------------------------------------------------------------------------------
/AWS/TerraformCognito/domain_r53.tf:
--------------------------------------------------------------------------------
1 | data "aws_route53_zone" "customdomain" {
2 | name = var.domain_name
3 | }
4 |
5 | resource "aws_route53_record" "cognito_dns" {
6 | zone_id = data.aws_route53_zone.customdomain.zone_id
7 | name = var.custom_domain_name
8 | type = "A"
9 | alias {
10 |
11 | name=module.aws_cognito_user_pool_complete_example.domain_cloudfront_distribution_arn
12 | //Specify Z2FDTNDATAQYW2. This is always the hosted zone ID when you create an alias record that routes traffic to a CloudFront distribution.
13 | //https://medium.com/@prity315/read-this-before-using-terraform-for-aws-cognito-a660bf1770d
14 | zone_id="Z2FDTNDATAQYW2"
15 | evaluate_target_health = false
16 | }
17 | }
18 |
19 | output "cfarn"{
20 | value=replace(module.aws_cognito_user_pool_complete_example.domain_cloudfront_distribution_arn, ".cloudfront.net", "")
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/AWS/TerraformCognito/presignup_cognito.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/TerraformCognito/presignup_cognito.zip
--------------------------------------------------------------------------------
/AWS/TerraformCognito/presignup_cognito/index.js:
--------------------------------------------------------------------------------
1 | exports.handler = (event, context, callback) => {
2 | // Set the user pool autoConfirmUser flag after validating the email domain
3 | event.response.autoConfirmUser = true;
4 | // Return to Amazon Cognito
5 | callback(null, event);
6 | };
--------------------------------------------------------------------------------
/AWS/TerraformCognito/providers.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_providers {
3 | aws = {
4 | source = "hashicorp/aws"
5 | version = "~> 3.0"
6 | }
7 | random = {
8 | source = "hashicorp/random"
9 | version = "~> 3.1.0"
10 | }
11 | archive = {
12 | source = "hashicorp/archive"
13 | version = "~> 2.2.0"
14 | }
15 | }
16 | }
17 |
18 | # Configure the AWS Provider
19 | provider "aws" {
20 | region = var.region
21 | }
22 |
--------------------------------------------------------------------------------
/AWS/TerraformCognito/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "us-east-1"
3 | }
4 |
5 | variable "prefix" {
6 | default = "travelservice"
7 | }
8 |
9 | variable "redirect_url"{
10 | default="http://localhost:3000/"
11 | }
12 | variable "callback_url"{
13 | default="http://localhost:3000/"
14 | }
15 | variable "logout_url"{
16 | default="http://localhost:3000/"
17 | }
18 |
19 | variable "reply_to_email_address"{
20 | default="a.pavithraa@gmail.com"
21 | }
22 | variable "domain_name" {
23 | default="pavithraavasudevan.com"
24 |
25 | }
26 | variable "custom_domain_name"{
27 | default="newauth.pavithraavasudevan.com"
28 | }
29 |
30 | variable "certificate_arn"{
31 |
32 | }
33 |
34 | variable "google_client_id"{
35 |
36 | }
37 | variable "google_client_secret"{
38 |
39 | }
--------------------------------------------------------------------------------
/AWS/TerraformECS/.gitignore:
--------------------------------------------------------------------------------
1 | *.tfvars
2 | *.tfstate
3 | *.tfstate.backup
4 | .terraform
5 | *.pem
6 | *.ppk
--------------------------------------------------------------------------------
/AWS/TerraformECS/.terraform.lock.hcl:
--------------------------------------------------------------------------------
1 | # This file is maintained automatically by "terraform init".
2 | # Manual edits may be lost in future updates.
3 |
4 | provider "registry.terraform.io/hashicorp/aws" {
5 | version = "3.52.0"
6 | constraints = ">= 2.42.0, >= 2.65.0, >= 2.70.0, ~> 3.0"
7 | hashes = [
8 | "h1:/dJnTVQFb4tQ4yFP4tUbP6EPPcGwze0XaewTUFE1R1c=",
9 | "zh:04a4f8a1b34292fd6a72c1efe03f6f10186ecbdc318df36d462d0be1c21ce72d",
10 | "zh:0601006f14f437489902555720dd8fb4e67450356438bab64b61cf6d0e1af681",
11 | "zh:14214e996b8db0a2038b74a2ddbea7356b3e53f73003cde2c9069294d9a6c421",
12 | "zh:17d1ecc280d776271b0fc0fd6a4033933be8e67eb6a39b7bfb3c242cd218645f",
13 | "zh:247ae4bc3b52fba96ed1593e7b23d62da0d2c99498fc0d968fcf28020df3c3aa",
14 | "zh:2e0432fabeb5e44d756a5566168768f1b6dea3cc0e5650fac966820e90d18367",
15 | "zh:34f6f95b88c5d8c105d9a3b7d2712e7df1181948bfbef33bb6a87d7a77c20c0d",
16 | "zh:3de6bf02b9499bf8dc13843da72a03db5ae8188b8157f0e7b3d5bf1d7cd1ac8b",
17 | "zh:43198a223ea6d6dfb82deac62b29181c3be18dc77b9ef9f8d44c32b08e44ea5c",
18 | "zh:a7de44c9445c100a2823c371df03fcaa9ecb1642750ccdc02294fa6cd1095859",
19 | "zh:c3c44bd07e5b6cdb776ff674e39feb708ba3ee3d0dff2c88d1d5db323094d942",
20 | ]
21 | }
22 |
23 | provider "registry.terraform.io/hashicorp/null" {
24 | version = "3.1.0"
25 | constraints = "~> 3.0"
26 | hashes = [
27 | "h1:SFT7X3zY18CLWjoH2GfQyapxsRv6GDKsy9cF1aRwncc=",
28 | "zh:02a1675fd8de126a00460942aaae242e65ca3380b5bb192e8773ef3da9073fd2",
29 | "zh:53e30545ff8926a8e30ad30648991ca8b93b6fa496272cd23b26763c8ee84515",
30 | "zh:5f9200bf708913621d0f6514179d89700e9aa3097c77dac730e8ba6e5901d521",
31 | "zh:9ebf4d9704faba06b3ec7242c773c0fbfe12d62db7d00356d4f55385fc69bfb2",
32 | "zh:a6576c81adc70326e4e1c999c04ad9ca37113a6e925aefab4765e5a5198efa7e",
33 | "zh:a8a42d13346347aff6c63a37cda9b2c6aa5cc384a55b2fe6d6adfa390e609c53",
34 | "zh:c797744d08a5307d50210e0454f91ca4d1c7621c68740441cf4579390452321d",
35 | "zh:cecb6a304046df34c11229f20a80b24b1603960b794d68361a67c5efe58e62b8",
36 | "zh:e1371aa1e502000d9974cfaff5be4cfa02f47b17400005a16f14d2ef30dc2a70",
37 | "zh:fc39cc1fe71234a0b0369d5c5c7f876c71b956d23d7d6f518289737a001ba69b",
38 | "zh:fea4227271ebf7d9e2b61b89ce2328c7262acd9fd190e1fd6d15a591abfa848e",
39 | ]
40 | }
41 |
--------------------------------------------------------------------------------
/AWS/TerraformECS/README copy.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/AWS/TerraformECS/README.md:
--------------------------------------------------------------------------------
1 | Creates the following resources:
2 |
3 | - VPC
4 | - 2 Public Subnets
5 | - 2 Private Subnets
6 | - Application Load Balancer
7 | - ECS Fargate
8 | - Bastion
9 | - DynamoDB
10 | - IAM Roles for task and task execution
11 | - S3 bucket for static website hosting
12 | - Cloud Front
13 | - SSL Certificate for the domain
14 | - Route 53 records for load balancer and cloud front
15 |
16 |
17 | Pre-requisites:
18 | Domain must be hosted at Route53
19 |
20 |
21 | I have not checked in terraform.tfvars. Values for the below variables have to be added in tfvars:
22 | instance_type
23 | instance_keypair
24 | container_name
25 | domain_name
26 | bucket_name
27 | VPC CIDR Block (subnets CIDRs will be calculated based on VPC CIDR. No need to configure separately)
28 |
29 |
--------------------------------------------------------------------------------
/AWS/TerraformECS/alb_output.tf:
--------------------------------------------------------------------------------
1 | # Terraform AWS Application Load Balancer (ALB) Outputs
2 | output "lb_id" {
3 | description = "The ID and ARN of the load balancer we created."
4 | value = module.alb.lb_id
5 | }
6 |
7 | output "lb_arn" {
8 | description = "The ID and ARN of the load balancer we created."
9 | value = module.alb.lb_arn
10 | }
11 |
12 | output "lb_dns_name" {
13 | description = "The DNS name of the load balancer."
14 | value = module.alb.lb_dns_name
15 | }
16 |
17 | output "lb_arn_suffix" {
18 | description = "ARN suffix of our load balancer - can be used with CloudWatch."
19 | value = module.alb.lb_arn_suffix
20 | }
21 |
22 | output "lb_zone_id" {
23 | description = "The zone_id of the load balancer to assist with creating DNS records."
24 | value = module.alb.lb_zone_id
25 | }
26 |
27 | output "http_tcp_listener_arns" {
28 | description = "The ARN of the TCP and HTTP load balancer listeners created."
29 | value = module.alb.http_tcp_listener_arns
30 | }
31 |
32 | output "http_tcp_listener_ids" {
33 | description = "The IDs of the TCP and HTTP load balancer listeners created."
34 | value = module.alb.http_tcp_listener_ids
35 | }
36 |
37 | output "https_listener_arns" {
38 | description = "The ARNs of the HTTPS load balancer listeners created."
39 | value = module.alb.https_listener_arns
40 | }
41 |
42 | output "https_listener_ids" {
43 | description = "The IDs of the load balancer listeners created."
44 | value = module.alb.https_listener_ids
45 | }
46 |
47 | output "target_group_arns" {
48 | description = "ARNs of the target groups. Useful for passing to your Auto Scaling group."
49 | value = module.alb.target_group_arns
50 | }
51 |
52 | output "target_group_arn_suffixes" {
53 | description = "ARN suffixes of our target groups - can be used with CloudWatch."
54 | value = module.alb.target_group_arn_suffixes
55 | }
56 |
57 | output "target_group_names" {
58 | description = "Name of the target group. Useful for passing to your CodeDeploy Deployment Group."
59 | value = module.alb.target_group_names
60 | }
61 |
62 | output "target_group_attachments" {
63 | description = "ARNs of the target group attachment IDs."
64 | value = module.alb.target_group_attachments
65 | }
66 |
--------------------------------------------------------------------------------
/AWS/TerraformECS/ecs_output.tf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/AWS/TerraformECS/ecs_output.tf
--------------------------------------------------------------------------------
/AWS/TerraformECS/ecs_variables.tf:
--------------------------------------------------------------------------------
1 | variable "cluster_name" {
2 | description = "Name of the cluster"
3 | type = string
4 | }
5 |
6 |
7 | variable "app_count" {
8 | default = 1
9 | type = number
10 | }
11 |
12 | variable "container_name" {
13 | description = "Container name to be used for application in task definition file"
14 | type = string
15 | }
16 |
17 | variable "api_image" {
18 | description = "Container image to be used for application in task definition file"
19 | type = string
20 | }
21 |
22 |
23 | variable "sec_container_name" {
24 | description = "Container name to be used for application in task definition file"
25 | type = string
26 | }
27 |
28 | variable "sec_image" {
29 | description = "Container image to be used for application in task definition file"
30 | type = string
31 | }
32 |
33 | variable "fargate_cpu" {
34 | default = 2048
35 | }
36 |
37 | variable "fargate_memory" {
38 | default = 4096
39 | }
40 | variable "app_port" {
41 | description = "value"
42 | default = 8102
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/AWS/TerraformECS/locals.tf:
--------------------------------------------------------------------------------
1 | locals {
2 |
3 | name = "stockservice"
4 | computed_bucket_name = "${var.prefix}.${var.bucket_name}.${substr(uuid(), 0, 3)}"
5 | common_tags = {
6 | app = "StockService"
7 | version = "V1"
8 | }
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/AWS/TerraformECS/networking.tf:
--------------------------------------------------------------------------------
1 | module "vpc" {
2 | source = "terraform-aws-modules/vpc/aws"
3 | version = "2.78.0"
4 |
5 | name = "${var.prefix}-${var.vpc_name}"
6 | cidr = var.vpc_cidr_block
7 | azs = var.vpc_availability_zones
8 | public_subnets = [ cidrsubnet(var.vpc_cidr_block, 8, 0), cidrsubnet(var.vpc_cidr_block, 8, 2)]
9 | private_subnets = [ cidrsubnet(var.vpc_cidr_block, 8, 1), cidrsubnet(var.vpc_cidr_block, 8, 3)]
10 |
11 | enable_nat_gateway = var.vpc_enable_nat_gateway
12 | single_nat_gateway = var.vpc_single_nat_gateway
13 |
14 | enable_dns_hostnames = true
15 | enable_dns_support = true
16 |
17 | tags = local.common_tags
18 | vpc_tags = local.common_tags
19 |
20 |
21 | public_subnet_tags = {
22 | Type = "Public Subnets"
23 | }
24 | private_subnet_tags = {
25 | Type = "Private Subnets"
26 | }
27 |
28 | }
29 |
30 |
31 |
32 | resource "aws_vpc_endpoint" "dynamodb" {
33 | vpc_id = module.vpc.vpc_id
34 | service_name = "com.amazonaws.${var.region_name}.dynamodb"
35 | vpc_endpoint_type = "Gateway"
36 | route_table_ids = module.vpc.private_route_table_ids
37 | tags = {
38 | Name = "Dynamo DB VPC Endpoint Gateway - ${var.prefix}"
39 | Environment = var.prefix
40 | }
41 | }
--------------------------------------------------------------------------------
/AWS/TerraformECS/networking_output.tf:
--------------------------------------------------------------------------------
1 | output "vpc_id" {
2 | description = "The ID of the VPC"
3 | value = module.vpc.vpc_id
4 | }
5 |
6 | # VPC CIDR blocks
7 | output "vpc_cidr_block" {
8 | description = "The CIDR block of the VPC"
9 | value = module.vpc.vpc_cidr_block
10 | }
11 |
12 | output "default_route_table_id"{
13 | description = "Default Route table id"
14 | value = module.vpc.default_route_table_id
15 | }
16 |
17 | # VPC Private Subnets
18 | output "private_subnets" {
19 | description = "List of IDs of private subnets"
20 | value = module.vpc.private_subnets
21 | }
22 |
23 | # VPC Public Subnets
24 | output "public_subnets" {
25 | description = "List of IDs of public subnets"
26 | value = module.vpc.public_subnets
27 | }
28 |
29 | # VPC NAT gateway Public IP
30 | output "nat_public_ips" {
31 | description = "List of public Elastic IPs created for AWS NAT Gateway"
32 | value = module.vpc.nat_public_ips
33 | }
34 |
35 | # VPC AZs
36 | output "azs" {
37 | description = "A list of availability zones spefified as argument to this module"
38 | value = module.vpc.azs
39 | }
40 |
--------------------------------------------------------------------------------
/AWS/TerraformECS/networking_variables.tf:
--------------------------------------------------------------------------------
1 | variable "vpc_name" {
2 | description = "VPC Name"
3 | type = string
4 | default = "myvpc"
5 | }
6 |
7 | # VPC CIDR Block
8 | variable "vpc_cidr_block" {
9 | description = "VPC CIDR Block"
10 | type = string
11 | default = "10.16.0.0/16"
12 | }
13 |
14 | # VPC Availability Zones
15 | variable "vpc_availability_zones" {
16 | description = "VPC Availability Zones"
17 | type = list(string)
18 | default = ["us-east-1a", "us-east-1b"]
19 | }
20 |
21 |
22 | variable "vpc_enable_nat_gateway" {
23 | description = "Enable NAT Gateways for Private Subnets Outbound Communication"
24 | type = bool
25 | default = true
26 | }
27 |
28 | # VPC Single NAT Gateway (True or False)
29 | variable "vpc_single_nat_gateway" {
30 | description = "Enable only single NAT Gateway in one Availability Zone to save costs during our demos"
31 | type = bool
32 | default = true
33 | }
34 |
--------------------------------------------------------------------------------
/AWS/TerraformECS/providers.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 |
3 | required_providers {
4 | aws = {
5 | source = "hashicorp/aws"
6 | version = "~> 3.0"
7 | }
8 | null = {
9 | source = "hashicorp/null"
10 | version = "~> 3.0"
11 | }
12 | }
13 | }
14 |
15 | # Configure the AWS Provider
16 | provider "aws" {
17 | region = var.region_name
18 |
19 | }
--------------------------------------------------------------------------------
/AWS/TerraformECS/r53_acm.tf:
--------------------------------------------------------------------------------
1 | data "aws_route53_zone" "customdomain" {
2 | name = var.domain_name
3 | }
4 |
5 |
6 | resource "aws_route53_record" "apps_lb_dns" {
7 | zone_id = data.aws_route53_zone.customdomain.zone_id
8 | name = "${var.prefix}backend.${var.domain_name}"
9 | type = "A"
10 | alias {
11 | name = module.alb.lb_dns_name
12 | zone_id = module.alb.lb_zone_id
13 | evaluate_target_health = true
14 | }
15 | }
16 |
17 |
18 |
19 |
20 | module "acm" {
21 | source = "terraform-aws-modules/acm/aws"
22 | version = "3.0.0"
23 | domain_name = trimsuffix(data.aws_route53_zone.customdomain.name, ".")
24 | zone_id = data.aws_route53_zone.customdomain.zone_id
25 | subject_alternative_names = [
26 | "*.${var.domain_name}"
27 | ]
28 | tags = local.common_tags
29 | }
30 |
--------------------------------------------------------------------------------
/AWS/TerraformECS/r53_acm_output.tf:
--------------------------------------------------------------------------------
1 |
2 | output "customdomain_zoneid" {
3 | description = "The Hosted Zone id of the desired Hosted Zone"
4 | value = data.aws_route53_zone.customdomain.zone_id
5 | }
6 |
7 | output "customdomain_name" {
8 | description = " The Hosted Zone name of the desired Hosted Zone."
9 | value = data.aws_route53_zone.customdomain.name
10 | }
11 |
12 | output "this_acm_certificate_arn" {
13 | description = "The ARN of the certificate"
14 | value = module.acm.acm_certificate_arn
15 | }
--------------------------------------------------------------------------------
/AWS/TerraformECS/security_group_output.tf:
--------------------------------------------------------------------------------
1 |
2 |
3 | output "ecstask_sg_group_id" {
4 | description = "The ID of the security group"
5 | value = module.ecstask_sg.this_security_group_id
6 | }
7 |
8 | output "ecstask_sg_group_vpc_id" {
9 | description = "The VPC ID"
10 | value = module.ecstask_sg.this_security_group_vpc_id
11 | }
12 |
13 |
14 | output "ecstask_sg_group_name" {
15 | description = "The name of the security group"
16 | value = module.ecstask_sg.this_security_group_name
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/AWS/TerraformECS/security_groups.tf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | module "loadbalancer_sg" {
5 | source = "terraform-aws-modules/security-group/aws"
6 | version = "3.18.0"
7 |
8 | name = "loadbalancer-sg"
9 | description = "Security Group with HTTP open for entire Internet (IPv4 CIDR), egress ports are all world open"
10 | vpc_id = module.vpc.vpc_id
11 | # Ingress Rules & CIDR Blocks
12 | ingress_rules = ["http-80-tcp", "https-443-tcp"]
13 | ingress_cidr_blocks = ["0.0.0.0/0"]
14 | # Egress Rule - all-all open
15 | egress_rules = ["all-all"]
16 | tags = local.common_tags
17 |
18 | # Open to CIDRs blocks (rule or from_port+to_port+protocol+description)
19 | ingress_with_cidr_blocks = [
20 | {
21 | from_port = 81
22 | to_port = 81
23 | protocol = 6
24 | description = "Allow Port 81 from internet"
25 | cidr_blocks = "0.0.0.0/0"
26 | },
27 | ]
28 | }
29 |
30 | module "ecstask_sg" {
31 | source = "terraform-aws-modules/security-group/aws"
32 | version = "3.18.0"
33 | name = "ecs-sg"
34 | description = "Security Group with HTTP open for entire Internet (IPv4 CIDR), egress ports are all world open"
35 | vpc_id = module.vpc.vpc_id
36 | ingress_rules = ["http-80-tcp", "https-443-tcp"]
37 | ingress_with_cidr_blocks = [
38 |
39 | {
40 | from_port = 80
41 | to_port = 8102
42 | protocol = 6
43 | description = "Allow "
44 | cidr_blocks = module.vpc.vpc_cidr_block
45 | },
46 | {
47 | from_port = 8102
48 | to_port = 8102
49 | protocol = 6
50 | description = "Allow "
51 | cidr_blocks = module.vpc.vpc_cidr_block
52 | },
53 | ]
54 | ingress_cidr_blocks = [module.vpc.vpc_cidr_block]
55 | egress_rules = ["all-all"]
56 | tags = local.common_tags
57 |
58 | }
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/AWS/TerraformECS/templates/s3-policy.json:
--------------------------------------------------------------------------------
1 | {
2 | "Version": "2012-10-17",
3 | "Statement": [
4 | {
5 | "Sid": "PublicReadGetObject",
6 | "Effect": "Allow",
7 | "Principal": "*",
8 | "Action": "s3:GetObject",
9 | "Resource": "arn:aws:s3:::${bucket}/*"
10 | }
11 | ]
12 | }
--------------------------------------------------------------------------------
/AWS/TerraformECS/variables.tf:
--------------------------------------------------------------------------------
1 | # root variables.tf
2 | variable "region_name" {
3 | default = "us-east-1"
4 | }
5 |
6 | variable "prefix" {
7 | default = "stockservice"
8 | }
9 | variable "domain_name" {
10 |
11 | }
12 | variable "instance_type" {
13 | default = "t3.micro"
14 | }
15 |
16 | variable "instance_keypair" {
17 | default = "terraformkey"
18 | }
19 |
20 | variable "private_instance_count" {
21 | default = 1
22 | }
23 |
24 | variable "bucket_name" {
25 | type = string
26 | description = "The name of the bucket without the www. prefix. Normally domain_name."
27 | }
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/AWS/TerraformEKS/.gitignore:
--------------------------------------------------------------------------------
1 | # Local .terraform directories
2 | **/.terraform/*
3 |
4 | # .tfstate files
5 | *.tfstate
6 | *.tfstate.*
7 |
8 | # Crash log files
9 | crash.log
10 |
11 | *.tfvars
12 | .terraform
13 | *.pem
14 | *.ppk
--------------------------------------------------------------------------------
/AWS/TerraformEKS/README.md:
--------------------------------------------------------------------------------
1 | Create terraform.tfvars with the following entries:
2 |
3 | account_id= AWS Account ID
4 |
5 | hosted_zone_id= ID of R53 Hosted Zone
6 |
--------------------------------------------------------------------------------
/AWS/TerraformEKS/dynamodb.tf:
--------------------------------------------------------------------------------
1 | module "dynamodb_table" {
2 | source = "terraform-aws-modules/dynamodb-table/aws"
3 | name = local.dynamodb_table_name
4 | hash_key = "username"
5 |
6 | attributes = [
7 | {
8 | name = "username"
9 | type = "S"
10 | }
11 | ]
12 |
13 | tags = local.common_tags
14 | }
--------------------------------------------------------------------------------
/AWS/TerraformEKS/dynamodb_output.tf:
--------------------------------------------------------------------------------
1 | output "dynamotable_arn" {
2 | description = "Dynamo table ARN"
3 | value = module.dynamodb_table.dynamodb_table_arn
4 | }
5 |
6 | output "dynamotable_id" {
7 | description = "Dynamo table ID"
8 | value = module.dynamodb_table.dynamodb_table_id
9 | }
--------------------------------------------------------------------------------
/AWS/TerraformEKS/eks-cluster.tf:
--------------------------------------------------------------------------------
1 | module "eks" {
2 | source = "terraform-aws-modules/eks/aws"
3 | cluster_name = local.cluster_name
4 | version = "17.24.0"
5 | cluster_version = "1.20"
6 | subnets = module.vpc.private_subnets
7 | attach_worker_cni_policy = true
8 | write_kubeconfig = true
9 |
10 | tags = {
11 | Environment = "training"
12 | GithubRepo = "terraform-aws-eks"
13 | GithubOrg = "terraform-aws-modules"
14 | }
15 |
16 | vpc_id = module.vpc.vpc_id
17 |
18 | workers_group_defaults = {
19 | root_volume_type = "gp2"
20 | }
21 |
22 | worker_groups = [
23 | {
24 | name = "worker-group-1"
25 | instance_type = var.instance_type
26 | asg_desired_capacity = 1
27 | additional_security_group_ids = [aws_security_group.worker_group_mgmt_one.id]
28 | },
29 | {
30 | name = "worker-group-2"
31 | instance_type = var.instance_type
32 | additional_security_group_ids = [aws_security_group.worker_group_mgmt_two.id]
33 | asg_desired_capacity = 1
34 | },
35 | ]
36 | }
37 |
38 |
39 | data "aws_eks_cluster" "cluster" {
40 | name = module.eks.cluster_id
41 | }
42 |
43 | data "aws_eks_cluster_auth" "cluster" {
44 | name = module.eks.cluster_id
45 | }
46 |
--------------------------------------------------------------------------------
/AWS/TerraformEKS/eks_output.tf:
--------------------------------------------------------------------------------
1 | output "cluster_id" {
2 | description = "EKS cluster ID."
3 | value = module.eks.cluster_id
4 | }
5 |
6 | output "cluster_endpoint" {
7 | description = "Endpoint for EKS control plane."
8 | value = module.eks.cluster_endpoint
9 | }
10 |
11 | output "cluster_security_group_id" {
12 | description = "Security group ids attached to the cluster control plane."
13 | value = module.eks.cluster_security_group_id
14 | }
15 |
16 |
17 | output "oidc" {
18 | description = "kubectl config as generated by the module."
19 | value = module.eks.cluster_oidc_issuer_url
20 | }
21 |
22 |
23 |
24 | output "region" {
25 | description = "AWS region"
26 | value = var.region
27 | }
28 |
29 | output "cluster_name" {
30 | description = "Kubernetes Cluster Name"
31 | value = local.cluster_name
32 | }
33 |
--------------------------------------------------------------------------------
/AWS/TerraformEKS/helm_chart_config/monitoring_custom_values.yml:
--------------------------------------------------------------------------------
1 | grafana:
2 | adminPassword: admin
3 | service:
4 | type: NodePort
--------------------------------------------------------------------------------
/AWS/TerraformEKS/iam-role.tf:
--------------------------------------------------------------------------------
1 | data "tls_certificate" "cluster" {
2 | url = module.eks.cluster_oidc_issuer_url
3 | }
4 | resource "aws_iam_openid_connect_provider" "cluster" {
5 | client_id_list = ["sts.amazonaws.com"]
6 | thumbprint_list = concat([data.tls_certificate.cluster.certificates.0.sha1_fingerprint], var.oidc_thumbprint_list)
7 | url = module.eks.cluster_oidc_issuer_url
8 | }
9 |
10 | output "aws_iam_openid_connect_provider_arn" {
11 | value = join("", aws_iam_openid_connect_provider.cluster.*.arn)
12 | }
--------------------------------------------------------------------------------
/AWS/TerraformEKS/ingress.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | # Your AWS EKS Cluster ID goes here.
3 | k8s_cluster_name = module.eks.cluster_id
4 | }
5 |
6 | data "aws_region" "current" {}
7 |
8 | data "aws_eks_cluster" "target" {
9 | name = local.k8s_cluster_name
10 | }
11 |
12 |
13 | data "aws_eks_cluster_auth" "aws_iam_authenticator" {
14 | name = data.aws_eks_cluster.target.name
15 | }
16 | provider "kubernetes" {
17 | alias = "eks"
18 | host = data.aws_eks_cluster.target.endpoint
19 | cluster_ca_certificate = base64decode(data.aws_eks_cluster.target.certificate_authority[0].data)
20 | token = data.aws_eks_cluster_auth.aws_iam_authenticator.token
21 |
22 | }
23 |
24 | module "alb_ingress_controller" {
25 | source = "iplabs/alb-ingress-controller/kubernetes"
26 | version = "3.4.0"
27 |
28 | providers = {
29 | kubernetes = kubernetes.eks
30 | }
31 |
32 | k8s_cluster_type = "eks"
33 | k8s_namespace = "kube-system"
34 |
35 | aws_region_name = data.aws_region.current.name
36 | k8s_cluster_name = data.aws_eks_cluster.target.name
37 | }
--------------------------------------------------------------------------------
/AWS/TerraformEKS/ingressalb.tf:
--------------------------------------------------------------------------------
1 | /*data "kubernetes_service" "ingress_nginx" {
2 | metadata {
3 | name = "${helm_release.ingress_nginx.name}-nginx-ingress-controller"
4 | namespace = kubernetes_namespace.ingress_nginx.metadata[0].name
5 | }
6 | }
7 |
8 | output "ingress_hostname" {
9 | value = data.kubernetes_service.ingress_nginx.load_balancer_ingress[0].hostname
10 | }*/
--------------------------------------------------------------------------------
/AWS/TerraformEKS/k8s_service_account.tf:
--------------------------------------------------------------------------------
1 | data "aws_caller_identity" "current" {}
2 |
3 | module "k8_service_account" {
4 | for_each = { for i in local.service_account_policies : i.name => i }
5 | source = "./service_accounts"
6 | name = each.value.name
7 | description = each.value.description
8 | account_id = data.aws_caller_identity.current.account_id
9 | path = each.value.path
10 | policy = each.value.policy
11 | k8s_service_account_namespace = local.k8s_service_account_namespace
12 | k8s_service_account_name = each.value.service_account_name
13 | oidc_issuer_url = module.eks.cluster_oidc_issuer_url
14 | depends_on = [
15 | module.dynamodb_table
16 | ]
17 | }
--------------------------------------------------------------------------------
/AWS/TerraformEKS/kube_prometheus_stack.tf:
--------------------------------------------------------------------------------
1 | provider "helm" {
2 | kubernetes {
3 | host = data.aws_eks_cluster.cluster.endpoint
4 | token = data.aws_eks_cluster_auth.cluster.token
5 | cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
6 | }
7 | }
8 |
9 |
10 | resource "helm_release" "kube_prometheus_stack" {
11 | name = "kube-prometheus-stack"
12 | repository = "https://prometheus-community.github.io/helm-charts"
13 | chart = "kube-prometheus-stack"
14 | values = [local.monitoring_values]
15 | }
--------------------------------------------------------------------------------
/AWS/TerraformEKS/kubernetes.tf:
--------------------------------------------------------------------------------
1 | # Kubernetes provider
2 | # https://learn.hashicorp.com/terraform/kubernetes/provision-eks-cluster#optional-configure-terraform-kubernetes-provider
3 | # To learn how to schedule deployments and services using the provider, go here: https://learn.hashicorp.com/terraform/kubernetes/deploy-nginx-kubernetes
4 |
5 | # The Kubernetes provider is included in this file so the EKS module can complete successfully. Otherwise, it throws an error when creating `kubernetes_config_map.aws_auth`.
6 | # You should **not** schedule deployments and services in this workspace. This keeps workspaces modular (one for provision EKS, another for scheduling Kubernetes resources) as per best practices.
7 |
8 | provider "kubernetes" {
9 | host = data.aws_eks_cluster.cluster.endpoint
10 | token = data.aws_eks_cluster_auth.cluster.token
11 | cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
12 | }
13 |
--------------------------------------------------------------------------------
/AWS/TerraformEKS/locals.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | cluster_name = "${var.prefix}-${random_string.suffix.result}"
3 | k8s_service_account_namespace = "default"
4 | k8s_service_account_name = "hotelservice"
5 | k8s_externaldns_service_account_name = "external-dns"
6 | dynamodb_table_name = "BookmarkedHotels"
7 | cluster_version = "1.21"
8 |
9 | common_tags = {
10 | app = "${var.prefix}"
11 | version = "V1"
12 | }
13 | monitoring_values = file(
14 | "${path.module}/helm_chart_config/monitoring_custom_values.yml")
15 |
16 | service_account_policies = [{
17 | name = "dynamodb_access_policy"
18 | description = "DynamoDB Access Policy"
19 | service_account_name = "hotelservice"
20 | path = "/"
21 | policy = jsonencode({
22 | "Version" : "2012-10-17",
23 | "Statement" : [
24 | {
25 |
26 | "Effect" : "Allow",
27 | "Action" : ["dynamodb:*"],
28 | "Resource" : "arn:aws:dynamodb:${var.region}:${var.account_id}:table/${local.dynamodb_table_name}"
29 | }
30 | ]
31 | })
32 |
33 | }, {
34 | name = "externaldns_access_policy"
35 | service_account_name = "external-dns"
36 | description = "External DNS Access Policy"
37 | path = "/"
38 | policy = jsonencode({
39 | "Version" : "2012-10-17",
40 | "Statement" : [
41 | {
42 | "Effect" : "Allow",
43 | "Action" : [
44 | "route53:ChangeResourceRecordSets"
45 | ],
46 | "Resource" : [
47 | "arn:aws:route53:::hostedzone/${var.hosted_zone_id}"
48 | ]
49 | },
50 | {
51 | "Effect" : "Allow",
52 | "Action" : [
53 | "route53:ListHostedZones",
54 | "route53:ListResourceRecordSets"
55 | ],
56 | "Resource" : [
57 | "*"
58 | ]
59 | }
60 | ]
61 | })
62 |
63 | }]
64 | }
65 |
--------------------------------------------------------------------------------
/AWS/TerraformEKS/oidc_assume_role_policy.json:
--------------------------------------------------------------------------------
1 | {
2 | "Version": "2012-10-17",
3 | "Statement": [
4 | {
5 | "Effect": "Allow",
6 | "Principal": {
7 | "Federated": "${OIDC_ARN}"
8 | },
9 | "Action": "sts:AssumeRoleWithWebIdentity",
10 | "Condition": {
11 | "StringEquals": {
12 | "${OIDC_URL}:sub": "system:serviceaccount:${NAMESPACE}:${SA_NAME}"
13 | }
14 | }
15 | }
16 | ]
17 | }
--------------------------------------------------------------------------------
/AWS/TerraformEKS/security-groups.tf:
--------------------------------------------------------------------------------
1 |
2 | resource "aws_security_group" "worker_group_mgmt_one" {
3 | name_prefix = "worker_group_mgmt_one"
4 | vpc_id = module.vpc.vpc_id
5 |
6 | ingress {
7 | from_port = 22
8 | to_port = 22
9 | protocol = "tcp"
10 |
11 | cidr_blocks = [
12 | "10.0.0.0/8",
13 | ]
14 | }
15 | }
16 |
17 | resource "aws_security_group" "worker_group_mgmt_two" {
18 | name_prefix = "worker_group_mgmt_two"
19 | vpc_id = module.vpc.vpc_id
20 |
21 | ingress {
22 | from_port = 22
23 | to_port = 22
24 | protocol = "tcp"
25 |
26 | cidr_blocks = [
27 | "192.168.0.0/16",
28 | ]
29 | }
30 | }
31 |
32 | resource "aws_security_group" "all_worker_mgmt" {
33 | name_prefix = "all_worker_management"
34 | vpc_id = module.vpc.vpc_id
35 |
36 | ingress {
37 | from_port = 22
38 | to_port = 22
39 | protocol = "tcp"
40 |
41 | cidr_blocks = [
42 | "10.0.0.0/8",
43 | "172.16.0.0/12",
44 | "192.168.0.0/16",
45 | ]
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/AWS/TerraformEKS/service_accounts/main.tf:
--------------------------------------------------------------------------------
1 | resource "aws_iam_policy" "awsservicepolicy" {
2 | name = var.name
3 | path = var.path
4 | description = var.description
5 |
6 | policy = var.policy
7 | }
8 |
9 | data "aws_iam_policy_document" "sa_service_role" {
10 | statement {
11 | actions = ["sts:AssumeRoleWithWebIdentity"]
12 |
13 | principals {
14 | type = "Federated"
15 | identifiers = [
16 | "arn:aws:iam::${var.account_id}:oidc-provider/${replace(var.oidc_issuer_url, "https://", "")}"
17 | ]
18 | }
19 |
20 | condition {
21 | test = "StringEquals"
22 | variable = "${replace(var.oidc_issuer_url, "https://", "")}:sub"
23 | values = [
24 | "system:serviceaccount:${var.k8s_service_account_namespace}:${var.k8s_service_account_name}"
25 | ]
26 | }
27 | condition {
28 | test = "StringEquals"
29 | variable = "${replace(var.oidc_issuer_url, "https://", "")}:aud"
30 | values = [
31 | "sts.amazonaws.com"
32 | ]
33 | }
34 | }
35 | }
36 | resource "random_string" "random" {
37 | length = 10
38 | special = false
39 |
40 | }
41 | resource "aws_iam_role" "sa_service_role" {
42 | name = "sa-awsservice-role-${random_string.random.result}"
43 | assume_role_policy = data.aws_iam_policy_document.sa_service_role.json
44 | }
45 |
46 | resource "aws_iam_role_policy_attachment" "test-attach" {
47 | role = aws_iam_role.sa_service_role.name
48 | policy_arn = aws_iam_policy.awsservicepolicy.arn
49 | }
50 |
51 | resource "kubernetes_service_account" "sa_service_role" {
52 | metadata {
53 | name = var.k8s_service_account_name
54 | namespace = var.k8s_service_account_namespace
55 | annotations = {
56 | "eks.amazonaws.com/role-arn" = aws_iam_role.sa_service_role.arn
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/AWS/TerraformEKS/service_accounts/variables.tf:
--------------------------------------------------------------------------------
1 | variable "name"{
2 | description = "Name of the policy"
3 | }
4 |
5 | variable "path"{
6 |
7 | }
8 |
9 | variable "description"{
10 | description = "Description of the policy"
11 | }
12 |
13 |
14 | variable "policy"{
15 | description = "Policy statement"
16 | }
17 |
18 | variable "k8s_service_account_namespace" {
19 |
20 | }
21 | variable "k8s_service_account_name" {
22 |
23 | }
24 | variable "account_id" {
25 |
26 | }
27 | variable "oidc_issuer_url" {
28 |
29 | }
--------------------------------------------------------------------------------
/AWS/TerraformEKS/variables.tf:
--------------------------------------------------------------------------------
1 | variable "oidc_thumbprint_list" {
2 | type = list(any)
3 | default = []
4 | }
5 |
6 | variable "region" {
7 | default = "us-east-1"
8 | }
9 | variable "account_id" {
10 | description = "Account ID"
11 | }
12 |
13 | variable "prefix" {
14 | default = "travelservice"
15 | }
16 |
17 | variable "instance_type" {
18 | default = "t2.medium"
19 | }
20 |
21 | variable "vpc_cidr_block" {
22 | description = "VPC CIDR Block"
23 | type = string
24 | default = "10.16.0.0/16"
25 | }
26 |
27 | variable "hosted_zone_id" {
28 | description = "Hosted Zone Id for External DNS service account"
29 | type = string
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/AWS/TerraformEKS/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_providers {
3 | aws = {
4 | source = "hashicorp/aws"
5 | version = ">= 3.20.0"
6 | }
7 |
8 | random = {
9 | source = "hashicorp/random"
10 | version = "3.1.0"
11 | }
12 |
13 | local = {
14 | source = "hashicorp/local"
15 | version = "2.1.0"
16 | }
17 |
18 | null = {
19 | source = "hashicorp/null"
20 | version = "3.1.0"
21 | }
22 |
23 | kubernetes = {
24 | source = "hashicorp/kubernetes"
25 | version = ">= 2.0.1"
26 | }
27 | }
28 |
29 | required_version = "> 0.14"
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/AWS/TerraformEKS/vpc.tf:
--------------------------------------------------------------------------------
1 |
2 | provider "aws" {
3 | region = var.region
4 | }
5 |
6 | data "aws_availability_zones" "available" {}
7 |
8 |
9 |
10 | resource "random_string" "suffix" {
11 | length = 8
12 | special = false
13 | }
14 |
15 | module "vpc" {
16 | source = "terraform-aws-modules/vpc/aws"
17 | version = "3.2.0"
18 |
19 | name = "education-vpc"
20 | cidr = var.vpc_cidr_block
21 | azs = data.aws_availability_zones.available.names
22 | private_subnets = [cidrsubnet(var.vpc_cidr_block, 8, 0), cidrsubnet(var.vpc_cidr_block, 8, 2), cidrsubnet(var.vpc_cidr_block, 8, 3)]
23 | public_subnets = [cidrsubnet(var.vpc_cidr_block, 8, 4), cidrsubnet(var.vpc_cidr_block, 8, 5), cidrsubnet(var.vpc_cidr_block, 8, 6)]
24 | enable_nat_gateway = true
25 | single_nat_gateway = true
26 | enable_dns_hostnames = true
27 |
28 | tags = {
29 | "kubernetes.io/cluster/${local.cluster_name}" = "shared"
30 | }
31 |
32 | public_subnet_tags = {
33 | "kubernetes.io/cluster/${local.cluster_name}" = "shared"
34 | "kubernetes.io/role/elb" = "1"
35 | }
36 |
37 | private_subnet_tags = {
38 | "kubernetes.io/cluster/${local.cluster_name}" = "shared"
39 | "kubernetes.io/role/internal-elb" = "1"
40 | }
41 | }
42 |
43 | resource "aws_vpc_endpoint" "dynamodb" {
44 | vpc_id = module.vpc.vpc_id
45 | service_name = "com.amazonaws.${var.region}.dynamodb"
46 | vpc_endpoint_type = "Gateway"
47 | route_table_ids = module.vpc.private_route_table_ids
48 | tags = {
49 | Name = "Dynamo DB VPC Endpoint Gateway - ${var.prefix}"
50 | Environment = var.prefix
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/AWS/TerraformS3DNS/.gitignore:
--------------------------------------------------------------------------------
1 | *.tfvars
2 | *.tfstate
3 | *.tfstate.backup
4 | .terraform
5 | *.pem
6 | *.ppk
--------------------------------------------------------------------------------
/AWS/TerraformS3DNS/README.md:
--------------------------------------------------------------------------------
1 | Create terraform.tfvars with the following entries
2 |
3 | ```
4 | domain_name = <>
5 | bucket_name = <>
6 | ```
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AWS/TerraformS3DNS/cloudfront.tf:
--------------------------------------------------------------------------------
1 |
2 | resource "aws_cloudfront_distribution" "travel_service_distribution" {
3 | origin {
4 | domain_name = aws_s3_bucket.websitebucket.website_endpoint
5 | origin_id = "S3-${local.computed_bucket_name}"
6 |
7 | custom_origin_config {
8 | http_port = 80
9 | https_port = 443
10 | origin_protocol_policy = "http-only"
11 | origin_ssl_protocols = ["TLSv1", "TLSv1.1", "TLSv1.2"]
12 | }
13 | }
14 |
15 | enabled = true
16 | is_ipv6_enabled = true
17 | default_root_object = "index.html"
18 |
19 | aliases = ["${var.prefix}.${var.domain_name}"]
20 |
21 | custom_error_response {
22 | error_caching_min_ttl = 0
23 | error_code = 404
24 | response_code = 200
25 | response_page_path = "/index.html"
26 | }
27 |
28 | default_cache_behavior {
29 | allowed_methods = ["GET", "HEAD"]
30 | cached_methods = ["GET", "HEAD"]
31 | target_origin_id = "S3-${local.computed_bucket_name}"
32 |
33 | forwarded_values {
34 | query_string = false
35 |
36 | cookies {
37 | forward = "none"
38 | }
39 | }
40 |
41 | viewer_protocol_policy = "redirect-to-https"
42 | min_ttl = 31536000
43 | default_ttl = 31536000
44 | max_ttl = 31536000
45 | compress = true
46 | }
47 |
48 | restrictions {
49 | geo_restriction {
50 | restriction_type = "none"
51 | }
52 | }
53 |
54 | viewer_certificate {
55 | acm_certificate_arn = module.acm.acm_certificate_arn
56 | ssl_support_method = "sni-only"
57 | minimum_protocol_version = "TLSv1.1_2016"
58 | }
59 |
60 | tags = local.common_tags
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/AWS/TerraformS3DNS/locals.tf:
--------------------------------------------------------------------------------
1 | locals {
2 |
3 | name = "travelpoc"
4 | computed_bucket_name = "${var.prefix}.${var.bucket_name}.${substr(uuid(), 0, 3)}"
5 | common_tags = {
6 | app = "TravelService"
7 | version = "V1"
8 | }
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/AWS/TerraformS3DNS/r53_acm_output.tf:
--------------------------------------------------------------------------------
1 |
2 | output "customdomain_zoneid" {
3 | description = "The Hosted Zone id of the desired Hosted Zone"
4 | value = data.aws_route53_zone.customdomain.zone_id
5 | }
6 |
7 | output "customdomain_name" {
8 | description = " The Hosted Zone name of the desired Hosted Zone."
9 | value = data.aws_route53_zone.customdomain.name
10 | }
11 |
12 | output "this_acm_certificate_arn" {
13 | description = "The ARN of the certificate"
14 | value = module.acm.acm_certificate_arn
15 | }
--------------------------------------------------------------------------------
/AWS/TerraformS3DNS/r53_acm_setup.tf:
--------------------------------------------------------------------------------
1 | data "aws_route53_zone" "customdomain" {
2 | name = var.domain_name
3 | }
4 |
5 |
6 |
7 | resource "aws_route53_record" "apps_dns" {
8 | zone_id = data.aws_route53_zone.customdomain.zone_id
9 | name = "${var.prefix}.${var.domain_name}"
10 | type = "A"
11 | alias {
12 | name = aws_cloudfront_distribution.travel_service_distribution.domain_name
13 | zone_id = aws_cloudfront_distribution.travel_service_distribution.hosted_zone_id
14 | evaluate_target_health = false
15 | }
16 | }
17 |
18 |
19 | module "acm" {
20 | source = "terraform-aws-modules/acm/aws"
21 | version = "3.0.0"
22 | domain_name = trimsuffix(data.aws_route53_zone.customdomain.name, ".")
23 | zone_id = data.aws_route53_zone.customdomain.zone_id
24 | subject_alternative_names = [
25 | "*.${var.domain_name}"
26 | ]
27 | tags = local.common_tags
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/AWS/TerraformS3DNS/s3.tf:
--------------------------------------------------------------------------------
1 |
2 | resource "aws_s3_bucket" "websitebucket" {
3 | bucket = local.computed_bucket_name
4 | acl = "public-read"
5 | policy = templatefile("templates/s3-policy.json", { bucket = "${local.computed_bucket_name}" })
6 |
7 | cors_rule {
8 | allowed_headers = ["Authorization", "Content-Length"]
9 | allowed_methods = ["GET", "POST"]
10 | allowed_origins = ["https://${var.prefix}.${var.domain_name}"]
11 | max_age_seconds = 3000
12 | }
13 |
14 | website {
15 | index_document = "index.html"
16 | error_document = "index.html"
17 | }
18 |
19 | tags = local.common_tags
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/AWS/TerraformS3DNS/s3_output.tf:
--------------------------------------------------------------------------------
1 | output "bucket_name" {
2 | value=local.computed_bucket_name
3 |
4 | }
5 |
6 |
--------------------------------------------------------------------------------
/AWS/TerraformS3DNS/templates/s3-policy.json:
--------------------------------------------------------------------------------
1 | {
2 | "Version": "2012-10-17",
3 | "Statement": [
4 | {
5 | "Sid": "PublicReadGetObject",
6 | "Effect": "Allow",
7 | "Principal": "*",
8 | "Action": "s3:GetObject",
9 | "Resource": "arn:aws:s3:::${bucket}/*"
10 | }
11 | ]
12 | }
--------------------------------------------------------------------------------
/AWS/TerraformS3DNS/variables.tf:
--------------------------------------------------------------------------------
1 |
2 |
3 | variable "region" {
4 | default = "us-east-1"
5 | }
6 |
7 |
8 | variable "prefix" {
9 | default = "hotelsearch"
10 | }
11 |
12 |
13 | variable "domain_name" {
14 |
15 | }
16 | variable "bucket_name" {
17 | type = string
18 | description = "The name of the bucket without the www. prefix. Normally domain_name."
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/AWS/TerraformS3DNS/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_providers {
3 | aws = {
4 | source = "hashicorp/aws"
5 | version = ">= 3.20.0"
6 | }
7 |
8 | random = {
9 | source = "hashicorp/random"
10 | version = "3.1.0"
11 | }
12 |
13 | local = {
14 | source = "hashicorp/local"
15 | version = "2.1.0"
16 | }
17 |
18 | null = {
19 | source = "hashicorp/null"
20 | version = "3.1.0"
21 | }
22 |
23 |
24 | }
25 |
26 | required_version = "> 0.14"
27 | }
28 |
29 | provider "aws" {
30 | region = var.region
31 |
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/Azure/AKSManifests/azure-pipelines.yml:
--------------------------------------------------------------------------------
1 | # Maven package Java project Web App to Linux on Azure
2 | # Build your Java project and deploy it to Azure as a Linux web app
3 | # Add steps that analyze code, save build artifacts, deploy, and more:
4 | # https://docs.microsoft.com/azure/devops/pipelines/languages/java
5 |
6 | trigger:
7 | - main
8 | stages:
9 | - stage: Build
10 | displayName: Build stage
11 | jobs:
12 | - job: PublishArtifacts
13 | displayName: Publish Artifacts
14 | pool:
15 | vmImage: ubuntu-latest
16 |
17 | steps:
18 |
19 |
20 | - task: PublishPipelineArtifact@1
21 | inputs:
22 | artifactName: 'manifests'
23 | path: 'manifests'
24 |
25 | - stage: Deploy
26 | displayName: Deploy stage
27 | dependsOn: Build
28 | jobs:
29 | - deployment: Deploy
30 | displayName: Deploy job
31 | pool:
32 | vmImage: ubuntu-latest
33 | environment: pills
34 |
35 | strategy:
36 | runOnce:
37 | deploy:
38 | steps:
39 | - task: DownloadPipelineArtifact@2
40 | inputs:
41 | artifactName: 'manifests'
42 | downloadPath: '$(System.ArtifactsDirectory)/manifests'
43 |
44 | - task: KubernetesManifest@0
45 | inputs:
46 | action: 'deploy'
47 | kubernetesServiceConnection: 'BookingServiceAKSConnection'
48 | namespace: 'default'
49 | manifests: '$(System.ArtifactsDirectory)/manifests/*.yml'
50 |
51 |
--------------------------------------------------------------------------------
/Azure/AKSManifests/manifests/Ingress.yml:
--------------------------------------------------------------------------------
1 | apiVersion: networking.k8s.io/v1beta1
2 | kind: Ingress
3 | metadata:
4 | name: bookingservice-ingress
5 | annotations:
6 | kubernetes.io/ingress.class: azure/application-gateway
7 | cert-manager.io/cluster-issuer: letsencrypt
8 |
9 | spec:
10 | rules:
11 | - host: bookingservice.saaralkaatru.com
12 | http:
13 | paths:
14 | - path: /
15 | backend:
16 | serviceName: hotel-service
17 | servicePort: 80
18 | tls:
19 | - hosts:
20 | # Need to updated with the domain name registered
21 | - bookingservice.saaralkaatru.com
22 | secretName: bookingservice-saaralkaatru-secret
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Azure/AKSManifests/manifests/azureutilityservice.yml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ConfigMap
3 | metadata:
4 | name: azure-utitlity-service
5 | data:
6 | spring.data.mongodb.database: <>
7 | #spring.data.mongodb.uri: mongodb://bookmarkedhotels:szVggF782fH1g5cjE1iyIkxiQRzQJu7fh2Y2A4nAIkGJSER5YvMToEeqSazRJPGyQZmTXx3Du5LGOgc5yjKryw==@bookmarkedhotels.mongo.cosmos.azure.com:10255/?ssl=true&retrywrites=false&replicaSet=globaldb&maxIdleTimeMS=120000&appName=@bookmarkedhotels@
8 | spring.data.mongodb.uri: << placeholder for connection string>>
9 | ---
10 | apiVersion: apps/v1
11 | kind: Deployment
12 | metadata:
13 | name: azure-utitlity-service
14 | labels:
15 | app: azure-utitlity-service
16 | spec:
17 | replicas: 1
18 | selector:
19 | matchLabels:
20 | app: azure-utitlity-service
21 | template:
22 | metadata:
23 | labels:
24 | app: azure-utitlity-service
25 | spec:
26 | containers:
27 | - name: azure-utitlity-service
28 | image: pavithravasudevan/azureutitlityservice:0.0.1-SNAPSHOT
29 | imagePullPolicy: Always
30 | resources:
31 | requests:
32 | cpu: "100m"
33 | memory: "256Mi"
34 | limits:
35 | cpu: "500m"
36 | memory: "512Mi"
37 |
38 | envFrom:
39 | - configMapRef:
40 | name: azure-utitlity-service
41 | ports:
42 | - containerPort: 8080
43 | ---
44 | apiVersion: v1
45 | kind: Service
46 | metadata:
47 | name: azure-utitlity-service
48 | spec:
49 | type: ClusterIP
50 | selector:
51 | app: azure-utitlity-service
52 | ports:
53 | - port: 80
54 | targetPort: 8080
--------------------------------------------------------------------------------
/Azure/AKSManifests/manifests/bookingservice.yml:
--------------------------------------------------------------------------------
1 |
2 | apiVersion: v1
3 | kind: ConfigMap
4 | metadata:
5 | name: hotel-service
6 | data:
7 | # Register and get the key from https://rapidapi.com/tipsters/api/booking-com/
8 | rapidapi.key: <>
9 | api.azureUtilityUrl: "azure-utitlity-service.default.svc.cluster.local"
10 | ---
11 | apiVersion: apps/v1
12 | kind: Deployment
13 | metadata:
14 | name: hotel-service
15 | labels:
16 | app: hotel-service
17 |
18 | spec:
19 | replicas: 1
20 | selector:
21 | matchLabels:
22 | app: hotel-service
23 | template:
24 | metadata:
25 | labels:
26 | app: hotel-service
27 | spec:
28 | containers:
29 | - name: hotel-service
30 | image: pavithravasudevan/hotelsearchserviceazure:0.0.1-SNAPSHOT
31 | imagePullPolicy: Always
32 | resources:
33 | requests:
34 | cpu: "100m"
35 | memory: "256Mi"
36 | limits:
37 | cpu: "500m"
38 | memory: "512Mi"
39 | envFrom:
40 | - configMapRef:
41 | name: hotel-service
42 | ports:
43 | - containerPort: 8103
44 | ---
45 | apiVersion: v1
46 | kind: Service
47 | metadata:
48 | name: hotel-service
49 | labels:
50 | app: hotel-service
51 | spec:
52 | type: ClusterIP
53 | selector:
54 | app: hotel-service
55 | ports:
56 | - port: 80
57 | targetPort: 8103
--------------------------------------------------------------------------------
/Azure/AKSManifests/manifests/cluster-issuer.yml:
--------------------------------------------------------------------------------
1 | apiVersion: cert-manager.io/v1
2 | kind: ClusterIssuer
3 | metadata:
4 | name: letsencrypt
5 | spec:
6 | acme:
7 | server: https://acme-v02.api.letsencrypt.org/directory
8 | # Need to replaced with email id
9 | email: test@gmail.com
10 | privateKeySecretRef:
11 | name: letsencrypt
12 | solvers:
13 | - http01:
14 | ingress:
15 | class: azure/application-gateway
16 |
17 |
--------------------------------------------------------------------------------
/Azure/SpringBootApps/azureutitlityservice/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/Azure/SpringBootApps/azureutitlityservice/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/Azure/SpringBootApps/azureutitlityservice/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/Azure/SpringBootApps/azureutitlityservice/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/Azure/SpringBootApps/azureutitlityservice/src/main/java/com/azureutilityservice/AzureutitlityserviceApplication.java:
--------------------------------------------------------------------------------
1 | package com.azureutilityservice;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class AzureutitlityserviceApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(AzureutitlityserviceApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/Azure/SpringBootApps/azureutitlityservice/src/main/java/com/azureutilityservice/repository/HotelRepository.java:
--------------------------------------------------------------------------------
1 | package com.azureutilityservice.repository;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.data.mongodb.repository.MongoRepository;
6 |
7 | import com.azureutitlityservice.model.BookmarkedHotels;
8 | import com.azureutitlityservice.model.HotelDetails;
9 |
10 |
11 |
12 |
13 | public interface HotelRepository extends MongoRepository{
14 |
15 |
16 | public BookmarkedHotels findByUsername(String userName);
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/Azure/SpringBootApps/azureutitlityservice/src/main/java/com/azureutitlityservice/model/BookmarkedHotels.java:
--------------------------------------------------------------------------------
1 | package com.azureutitlityservice.model;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.data.annotation.Id;
6 |
7 | import lombok.Data;
8 |
9 | @Data
10 | public class BookmarkedHotels {
11 |
12 | @Id
13 | public String id;
14 | private String username;
15 |
16 | private List hotelsList;
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/Azure/SpringBootApps/azureutitlityservice/src/main/java/com/azureutitlityservice/model/HotelDetails.java:
--------------------------------------------------------------------------------
1 | package com.azureutitlityservice.model;
2 |
3 | import java.io.Serializable;
4 |
5 | import lombok.Data;
6 |
7 | @Data
8 | public class HotelDetails implements Serializable{
9 | private String maxPhotoUrl;
10 | private String hotelName;
11 | private String cityName;
12 | private String country;
13 | private String distance;
14 | private String review;
15 | private double price;
16 | private int hotelId;
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/Azure/SpringBootApps/azureutitlityservice/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.data.mongodb.database=bookmarkedhotels
2 | spring.data.mongodb.uri=mongodb://bookmarkedhotels:szVggF782fH1g5cjE1iyIkxiQRzQJu7fh2Y2A4nAIkGJSER5YvMToEeqSazRJPGyQZmTXx3Du5LGOgc5yjKryw==@bookmarkedhotels.mongo.cosmos.azure.com:10255/?ssl=true&retrywrites=false&replicaSet=globaldb&maxIdleTimeMS=120000&appName=@bookmarkedhotels@
3 |
4 |
5 | server.port=8080
6 | spring.application.name=aws-utility-service
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Azure/SpringBootApps/azureutitlityservice/src/test/java/com/azureutilityservice/AzureutitlityserviceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.azureutilityservice;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class AzureutitlityserviceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/Azure/SpringBootApps/hotelsearchserviceazure/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/Azure/SpringBootApps/hotelsearchserviceazure/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/Azure/SpringBootApps/hotelsearchserviceazure/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/Azure/SpringBootApps/hotelsearchserviceazure/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
3 |
--------------------------------------------------------------------------------
/Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/ExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.hotelsearchservice;
2 |
3 | import java.net.http.HttpHeaders;
4 |
5 | import org.springframework.http.HttpStatus;
6 | import org.springframework.http.ResponseEntity;
7 | import org.springframework.web.bind.MethodArgumentNotValidException;
8 | import org.springframework.web.bind.annotation.ControllerAdvice;
9 | import org.springframework.web.context.request.WebRequest;
10 | import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
11 |
12 | import feign.FeignException.InternalServerError;
13 |
14 | @ControllerAdvice
15 | public class ExceptionHandler extends ResponseEntityExceptionHandler {
16 |
17 | protected ResponseEntity