├── 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 handleMethodArgumentNotValid(MethodArgumentNotValidException ex, 18 | HttpHeaders headers, HttpStatus status, WebRequest request) { 19 | 20 | return new ResponseEntity("Arguments not valid", HttpStatus.BAD_REQUEST); 21 | } 22 | protected ResponseEntity handleTooManyRequests(InternalServerError ex, 23 | HttpHeaders headers, HttpStatus status, WebRequest request) { 24 | 25 | return new ResponseEntity("Please try after sometime", HttpStatus.TOO_MANY_REQUESTS); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/dto/HotelSearchDto.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class HotelSearchDto { 9 | 10 | private String units; 11 | @JsonProperty("order_by") 12 | private String orderBy; 13 | @JsonProperty("order_by") 14 | private String checkoutDate; 15 | @JsonProperty("adults_number") 16 | private String adultsNumber; 17 | @JsonProperty("checkin_date") 18 | private String checkinDate; 19 | @JsonProperty("room_number") 20 | private int roomNumber; 21 | @JsonProperty("filter_by_currency") 22 | private String filterByCurrency; 23 | @JsonProperty("dest_type") 24 | private String destType; 25 | @JsonProperty("locale") 26 | private String locale; 27 | @JsonProperty("dest_id") 28 | private int destId; 29 | @JsonProperty("include_adjacency") 30 | private boolean includeAdjacency; 31 | @JsonProperty("page_number") 32 | private int pageNumber; 33 | @JsonProperty("children_number") 34 | private int childNumber; 35 | @JsonProperty("children_ages") 36 | private String childrenAges; 37 | 38 | 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/AllInclusiveAmount.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class AllInclusiveAmount implements Serializable{ 9 | private double value; 10 | private String currency; 11 | } 12 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Badge.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class Badge implements Serializable{ 9 | 10 | private String id; 11 | private String badge_variant; 12 | private String text; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Base.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Base implements Serializable{ 6 | private double percentage; 7 | private String kind; 8 | private double base_amount; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Benefit.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Benefit implements Serializable{ 6 | 7 | private Object icon; 8 | private String details; 9 | private String badge_variant; 10 | private String kind; 11 | private String name; 12 | private String identifier; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Block.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import lombok.Data; 7 | 8 | @Data 9 | public class Block implements Serializable{ 10 | private List credits; 11 | private String block_id; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/BookingHome.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class BookingHome implements Serializable { 9 | private int is_booking_home; 10 | private double quality_class; 11 | private String group; 12 | private int segment; 13 | private String is_single_unit_property; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Bwallet.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class Bwallet implements Serializable{ 9 | private int hotel_eligibility; 10 | } 11 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Checkin.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class Checkin implements Serializable { 9 | private String until; 10 | private String from; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Checkout.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Checkout implements Serializable{ 6 | private String from; 7 | private String until; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/CompositePriceBreakdown.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import lombok.Data; 7 | 8 | @Data 9 | public class CompositePriceBreakdown implements Serializable{ 10 | private List benefits; 11 | private GrossAmountPerNight gross_amount_per_night; 12 | private ExcludedAmount excluded_amount; 13 | private AllInclusiveAmount all_inclusive_amount; 14 | private List product_price_breakdowns; 15 | private List items; 16 | private NetAmount net_amount; 17 | private GrossAmount gross_amount; 18 | private IncludedTaxesAndChargesAmount included_taxes_and_charges_amount; 19 | private RewardAmount reward_amount; 20 | private DiscountedAmount discounted_amount; 21 | private StrikethroughAmountPerNight strikethrough_amount_per_night; 22 | private StrikethroughAmount strikethrough_amount; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Credit.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class Credit implements Serializable{ 9 | private double reward_amount; 10 | private String terms_conditions; 11 | private String reward_currency; 12 | } 13 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/DiscountedAmount.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | public class DiscountedAmount implements Serializable{ 6 | private String currency; 7 | private double value; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Distance.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class Distance implements Serializable{ 9 | 10 | private String icon_name; 11 | private Object icon_set; 12 | private String text; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/ExcludedAmount.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class ExcludedAmount implements Serializable{ 9 | private String currency; 10 | private int value; 11 | } 12 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/ExtraLinesDescription.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class ExtraLinesDescription implements Serializable{ 9 | private String imp_info; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/FavoriteHotel.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class FavoriteHotel 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/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/GrossAmount.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | public class GrossAmount implements Serializable{ 6 | private double value; 7 | private String currency; 8 | } 9 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/GrossAmountPerNight.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class GrossAmountPerNight implements Serializable { 9 | private double value; 10 | private String currency; 11 | } 12 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/HotelDescription.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class HotelDescription implements Serializable{ 9 | private int descriptiontype_id; 10 | private String languagecode; 11 | private String description; 12 | private ExtraLinesDescription extra_lines; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/HotelFacitlites.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class HotelFacitlites implements Serializable{ 9 | private int hotelfacilitytype_id; 10 | private int is_common_room_facility; 11 | private String kind; 12 | private String facilitytype_name; 13 | private String facility_name; 14 | private String roomfacilitytype_id; 15 | private int facilitytype_id; 16 | private int value; 17 | private int hotel_id; 18 | private int paid; 19 | private int free; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/HotelPhotos.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import lombok.Data; 7 | 8 | @Data 9 | public class HotelPhotos implements Serializable{ 10 | 11 | public int descriptiontype_id; 12 | public List ml_tags; 13 | public int photo_id; 14 | public List tags; 15 | public String url_square60; 16 | public String url_max; 17 | public String url_1440; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/HotelReview.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import lombok.Data; 8 | 9 | @Data 10 | public class HotelReview implements Serializable { 11 | 12 | private int count; 13 | private List result; 14 | private List sort_options; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Hotels.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import lombok.Data; 7 | 8 | @Data 9 | public class Hotels implements Serializable{ 10 | 11 | private int primary_count; 12 | private int count; 13 | private List room_distribution; 14 | private MapBoundingBox map_bounding_box; 15 | private int total_count_with_filters; 16 | private int unfiltered_count; 17 | private int extended_count; 18 | private int unfiltered_primary_count; 19 | private double search_radius; 20 | private List sort; 21 | private List result; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/IncludedTaxesAndChargesAmount.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class IncludedTaxesAndChargesAmount implements Serializable{ 9 | private String currency; 10 | private double value; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Item.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Item implements Serializable{ 6 | 7 | private String name; 8 | private ItemAmount item_amount; 9 | private String kind; 10 | private String details; 11 | private Base base; 12 | private String inclusion_type; 13 | private String identifier; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/ItemAmount.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class ItemAmount { 7 | private double value; 8 | private String currency; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/MapBoundingBox.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class MapBoundingBox implements Serializable{ 9 | 10 | private double sw_lat; 11 | private double ne_lat; 12 | private double ne_long; 13 | private double sw_long; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/MlTag.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class MlTag implements Serializable{ 9 | private int confidence; 10 | private String tag_name; 11 | private int tag_id; 12 | private String tag_type; 13 | private int photo_id; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/NetAmount.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class NetAmount implements Serializable{ 9 | private double value; 10 | private String currency; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/PriceBreakdown.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class PriceBreakdown implements Serializable{ 9 | 10 | private String currency; 11 | private double all_inclusive_price; 12 | private int has_tax_exceptions; 13 | private int has_incalculable_charges; 14 | private int has_fine_print_charges; 15 | private String sum_excluded_raw; 16 | private Object gross_price; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/ProductPriceBreakdown.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import lombok.Data; 7 | 8 | @Data 9 | public class ProductPriceBreakdown implements Serializable{ 10 | private GrossAmount gross_amount; 11 | private IncludedTaxesAndChargesAmount included_taxes_and_charges_amount; 12 | private List items; 13 | private NetAmount net_amount; 14 | private List benefits; 15 | private GrossAmountPerNight gross_amount_per_night; 16 | private ExcludedAmount excluded_amount; 17 | private AllInclusiveAmount all_inclusive_amount; 18 | private RewardAmount reward_amount; 19 | private DiscountedAmount discounted_amount; 20 | private StrikethroughAmountPerNight strikethrough_amount_per_night; 21 | private StrikethroughAmount strikethrough_amount; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/ReviewAuthor.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class ReviewAuthor implements Serializable{ 9 | 10 | private String type_string; 11 | private String countrycode; 12 | private int nr_reviews; 13 | private String name; 14 | private int user_id; 15 | private String city; 16 | private String type; 17 | private String age_group; 18 | private int helpful_vote_count; 19 | private String avatar; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/ReviewDetails.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | 6 | import lombok.Data; 7 | 8 | @Data 9 | public class ReviewDetails implements Serializable{ 10 | public double average_score; 11 | public int helpful_vote_count; 12 | public String anonymous; 13 | public Object review_id; 14 | public int is_moderated; 15 | public String review_hash; 16 | public String countrycode; 17 | public String pros_translated; 18 | public String title; 19 | public String languagecode; 20 | public String cons_translated; 21 | public String travel_purpose; 22 | public String hotelier_response; 23 | public ArrayList tags; 24 | public String date; 25 | public String title_translated; 26 | public ReviewAuthor author; 27 | public ArrayList reviewer_photos; 28 | public StayedRoomInfo stayed_room_info; 29 | public ArrayList user_new_badges; 30 | public int hotel_id; 31 | public String pros; 32 | public String hotelier_name; 33 | public int reviewng; 34 | public String cons; 35 | public int is_incentivised; 36 | public int is_trivial; 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/ReviewPhoto.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | 8 | @Data 9 | public class ReviewPhoto implements Serializable{ 10 | 11 | private String url_square60; 12 | private String url_640x200; 13 | private String url_max300; 14 | private int photo_id; 15 | private String url_original; 16 | private double ratio; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/ReviewerPhoto.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class ReviewerPhoto implements Serializable{ 9 | 10 | private String max1280x900; 11 | private String square90; 12 | private String square60_ao; 13 | private String max500_ao; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/RewardAmount.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class RewardAmount implements Serializable{ 9 | 10 | private double value; 11 | private String currency; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Rewards.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import lombok.Data; 7 | 8 | @Data 9 | public class Rewards implements Serializable{ 10 | 11 | private List blocks; 12 | private Total total; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/RoomDistribution.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import lombok.Data; 7 | 8 | @Data 9 | public class RoomDistribution implements Serializable{ 10 | private String adults; 11 | private List children; 12 | } 13 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Sort.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class Sort implements Serializable { 9 | private String name; 10 | private String id; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/StayedRoomInfo.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class StayedRoomInfo implements Serializable{ 9 | 10 | private int room_id; 11 | private String checkin; 12 | private String room_name; 13 | private ReviewPhoto photo; 14 | private String checkout; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/StrikethroughAmount.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class StrikethroughAmount implements Serializable{ 9 | 10 | private String currency; 11 | private double value; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/StrikethroughAmountPerNight.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class StrikethroughAmountPerNight implements Serializable{ 9 | private double value; 10 | private String currency; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/SumCredits.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class SumCredits implements Serializable{ 9 | private double reward_amount; 10 | private String reward_currency; 11 | } 12 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Tag.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | 5 | import lombok.Data; 6 | 7 | @Data 8 | public class Tag implements Serializable { 9 | private int id; 10 | private String tag; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/hotels/Total.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.hotels; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import lombok.Data; 7 | 8 | @Data 9 | public class Total implements Serializable{ 10 | private List credits; 11 | private SumCredits sum_credits; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/location/BMaxLosData.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.location; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class BMaxLosData { 7 | private int is_fullon; 8 | private int default_los; 9 | private String experiment; 10 | private int max_allowed_los; 11 | private int has_extended_los; 12 | private String extended_los; 13 | } 14 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/model/location/Location.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.model.location; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Location { 7 | 8 | private String lc; 9 | private String image_url; 10 | private String city_name; 11 | private String dest_id; 12 | private int landmark_type; 13 | private String label; 14 | private int city_ufi; 15 | private double longitude; 16 | private String country; 17 | private String dest_type; 18 | private String cc1; 19 | private double latitude; 20 | private int rtl; 21 | private String type; 22 | private String timezone; 23 | private String region; 24 | private int hotels; 25 | private BMaxLosData b_max_los_data; 26 | private String name; 27 | private int nr_hotels; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/restservice/AzureUtilityRestClient.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.restservice; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PostMapping; 8 | import org.springframework.web.bind.annotation.RequestBody; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | 11 | import com.hotelsearchservice.model.hotels.FavoriteHotel; 12 | 13 | @FeignClient(name = "azureUtilityClient", url = "${api.azureUtilityUrl}") 14 | public interface AzureUtilityRestClient { 15 | @GetMapping("/FavoriteHotels") 16 | public List getFavoriteHotels(@RequestParam String userName); 17 | 18 | @PostMapping("/FavoriteHotels") 19 | public void postFavoriteHotels(@RequestParam String userName,@RequestBody FavoriteHotel hotelDetails); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/restservice/FeignErrorDecoder.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.restservice; 2 | 3 | import feign.FeignException; 4 | import feign.Response; 5 | import feign.RetryableException; 6 | import feign.codec.ErrorDecoder; 7 | import java.util.Set; 8 | 9 | 10 | public class FeignErrorDecoder extends ErrorDecoder.Default { 11 | 12 | private final Set retryableStatusCodes; 13 | 14 | /** */ 15 | public FeignErrorDecoder(Set retryableStatusCodes) { 16 | this.retryableStatusCodes = retryableStatusCodes; 17 | } 18 | 19 | @Override 20 | public Exception decode(String methodKey, Response response) { 21 | // Default error decoder converts response to either FeignException or RetryableException(if 22 | // Retry-After header is present in response). 23 | 24 | Exception ex = super.decode(methodKey, response); 25 | if (ex instanceof RetryableException) { 26 | return ex; 27 | } else if (ex instanceof FeignException) { 28 | ex.printStackTrace(); 29 | FeignException feignException = (FeignException) ex; 30 | if (retryableStatusCodes.contains(feignException.status())) { 31 | return new RetryableException( 32 | 0, feignException.getMessage(), response.request().httpMethod(), feignException, null, null); 33 | } 34 | return feignException; 35 | } 36 | return ex; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/restservice/HotelBookingServiceFeignConfig.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.restservice; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.context.annotation.Bean; 5 | 6 | import feign.Retryer; 7 | import static java.util.concurrent.TimeUnit.SECONDS; 8 | 9 | import java.util.HashSet; 10 | import java.util.Set; 11 | 12 | import feign.RequestInterceptor; 13 | import feign.codec.ErrorDecoder; 14 | 15 | 16 | public class HotelBookingServiceFeignConfig { 17 | @Value("${rapidapi.key}") 18 | private String apiKey; 19 | @Value("${rapidapi.service}") 20 | private String service; 21 | 22 | @Bean 23 | public Retryer retryer() { 24 | return new Retryer.Default(100, SECONDS.toMillis(1), 3); 25 | } 26 | 27 | @Bean 28 | public RequestInterceptor feignRequestInterceptor() { 29 | 30 | return t -> t.header("x-rapidapi-key", apiKey).header("x-rapidapi-host", service); 31 | } 32 | 33 | @Bean 34 | public ErrorDecoder errorDecoder() { 35 | 36 | Set retryableStatusCodes = new HashSet<>(); 37 | retryableStatusCodes.add(500); 38 | retryableStatusCodes.add(503); 39 | 40 | return new FeignErrorDecoder(retryableStatusCodes); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/security/JwtAuthentication.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.security; 2 | 3 | import com.nimbusds.jwt.JWTClaimsSet; 4 | import org.springframework.security.authentication.AbstractAuthenticationToken; 5 | import org.springframework.security.core.GrantedAuthority; 6 | 7 | import java.util.Collection; 8 | 9 | public class JwtAuthentication extends AbstractAuthenticationToken { 10 | 11 | private final Object principal; 12 | private JWTClaimsSet jwtClaimsSet; 13 | 14 | public JwtAuthentication(Object principal, JWTClaimsSet jwtClaimsSet, Collection authorities) { 15 | super(authorities); 16 | this.principal = principal; 17 | this.jwtClaimsSet = jwtClaimsSet; 18 | super.setAuthenticated(true); 19 | } 20 | 21 | public Object getCredentials() { 22 | return null; 23 | } 24 | 25 | public Object getPrincipal() { 26 | return this.principal; 27 | } 28 | 29 | public JWTClaimsSet getJwtClaimsSet() { 30 | return this.jwtClaimsSet; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/security/JwtIdTokenCredentialsHolder.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.security; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class JwtIdTokenCredentialsHolder { 7 | private String idToken; 8 | 9 | public JwtIdTokenCredentialsHolder() { 10 | } 11 | 12 | public String getIdToken() { 13 | return this.idToken; 14 | } 15 | 16 | public JwtIdTokenCredentialsHolder setIdToken(String idToken) { 17 | this.idToken = idToken; 18 | return this; 19 | } 20 | } -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/java/com/hotelsearchservice/security/SecurityConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice.security; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 9 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 10 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 11 | import org.springframework.web.cors.CorsConfiguration; 12 | import org.springframework.web.cors.CorsConfigurationSource; 13 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; 14 | 15 | 16 | @Configuration 17 | public class SecurityConfiguration extends WebSecurityConfigurerAdapter { 18 | 19 | @Autowired 20 | private AzureADB2CJwtAuthFilter azureADB2CFilter; 21 | 22 | @Override 23 | protected void configure(HttpSecurity http) throws Exception { 24 | 25 | http.headers().cacheControl(); 26 | http.csrf().disable() 27 | .authorizeRequests() 28 | .antMatchers("**/health").permitAll() 29 | .antMatchers("/Hotel").permitAll() 30 | .antMatchers("/").permitAll() 31 | .antMatchers("/FavoriteHotels").authenticated() 32 | .and() 33 | .addFilterBefore(azureADB2CFilter, UsernamePasswordAuthenticationFilter.class); 34 | http.cors(); 35 | } 36 | 37 | @Bean 38 | public CorsConfigurationSource corsConfigurationSource() { 39 | final CorsConfiguration configuration = new CorsConfiguration(); 40 | configuration.setAllowedOrigins(List.of("*")); 41 | configuration.setAllowedMethods(List.of("HEAD", 42 | "GET", "POST", "PUT", "DELETE", "PATCH")); 43 | configuration.setAllowCredentials(false); 44 | configuration.setAllowedHeaders(List.of("Authorization", "Cache-Control", "Content-Type")); 45 | final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); 46 | source.registerCorsConfiguration("/**", configuration); 47 | return source; 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | server.port=8103 4 | 5 | 6 | server.forward-headers-strategy= native 7 | com.azuread.issuerUri=https://pocorgb2c.b2clogin.com/6cafadb0-b986-496c-a6cd-df08605f27c0/v2.0/ 8 | com.azuread.jwkSetUri=https://pocorgb2c.b2clogin.com/pocorgb2c.onmicrosoft.com/b2c_1_todo2101/discovery/v2.0/keys 9 | spring.cloud.config.import-check.enabled=false 10 | rapidapi.service=booking-com.p.rapidapi.com 11 | rapidapi.key=<> 12 | api.azureUtilityUrl=http://localhost:8080/ 13 | spring.jackson.serialization.write-date-keys-as-timestamps=false 14 | spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false 15 | 16 | resilience4j.retry.instances.locationapi.maxRetryAttempts=2 17 | resilience4j.retry.instances.locationapi.waitDuration=1s 18 | resilience4j.retry.instances.locationapi.enableExponentialBackoff=true 19 | 20 | resilience4j.retry.instances.hoteldetails.maxRetryAttempts=3 21 | resilience4j.retry.instances.hoteldetails.waitDuration=1s 22 | resilience4j.retry.instances.hoteldetails.enableExponentialBackoff=true 23 | 24 | #resilience4j.circuitbreaker.instances.default.failureRateThreshold=90 25 | resilience4j.ratelimiter.instances.locationapi.limitForPeriod=10 26 | resilience4j.ratelimiter.instances.locationapi.limitRefreshPeriod=5s 27 | -------------------------------------------------------------------------------- /Azure/SpringBootApps/hotelsearchserviceazure/src/test/java/com/hotelsearchservice/HotelsearchserviceazureApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hotelsearchservice; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class HotelsearchserviceazureApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Azure/TerraformAKS/.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 -------------------------------------------------------------------------------- /Azure/TerraformAKS/README.md: -------------------------------------------------------------------------------- 1 | Create terraform.tfvars with the following entries: 2 | 3 | dnszone_rg = Resource group of DNS Zone 4 | 5 | 6 | email_id = Mail Id 7 | 8 | domain_name = Registered Domain Name 9 | -------------------------------------------------------------------------------- /Azure/TerraformAKS/aks-roles.tf: -------------------------------------------------------------------------------- 1 | data "azurerm_user_assigned_identity" "ingressid" { 2 | name = "ingressapplicationgateway-${var.prefix}-aks" 3 | resource_group_name = module.aks.node_resource_group 4 | depends_on = [module.aks, azurerm_role_assignment.aks_dns_role] 5 | } 6 | 7 | 8 | resource "azurerm_role_assignment" "aks_dns_role" { 9 | scope = data.azurerm_resource_group.dnszone.id 10 | role_definition_name = data.azurerm_role_definition.contributor.name 11 | principal_id = module.aks.kubelet_identity[0].object_id 12 | } 13 | 14 | resource "azurerm_role_assignment" "aks_network_role" { 15 | scope = azurerm_resource_group.aksresgroup.id 16 | role_definition_name = data.azurerm_role_definition.contributor.name 17 | principal_id = module.aks.kubelet_identity[0].object_id 18 | } 19 | 20 | //data "azurerm_subscription" "primary" {} 21 | // dependency is added to postpone for rectifying the 22 | resource "azurerm_role_assignment" "aks_accessvnet_role" { 23 | 24 | scope = azurerm_resource_group.aksresgroup.id 25 | role_definition_name = "Contributor" 26 | principal_id = data.azurerm_user_assigned_identity.ingressid.principal_id 27 | //client_id=data.azurerm_user_assigned_identity.ingressid.client_id 28 | depends_on = [module.aks, azurerm_role_assignment.aks_dns_role] 29 | } 30 | 31 | resource "azurerm_role_assignment" "aks_networkingress_role" { 32 | scope = module.network.vnet_id 33 | role_definition_name = "Network Contributor" 34 | principal_id = data.azurerm_user_assigned_identity.ingressid.principal_id 35 | 36 | depends_on = [module.aks] 37 | } 38 | -------------------------------------------------------------------------------- /Azure/TerraformAKS/aks_output.tf: -------------------------------------------------------------------------------- 1 | output "aks_identity" { 2 | value = module.aks.system_assigned_identity 3 | } 4 | 5 | output "aks_user_identity" { 6 | value = module.aks.kubelet_identity 7 | } 8 | 9 | output "node_resource_group" { 10 | value = module.aks.node_resource_group 11 | } 12 | 13 | 14 | output "uai_client_id" { 15 | value = data.azurerm_user_assigned_identity.ingressid.client_id 16 | } 17 | 18 | output "uai_principal_id" { 19 | value = data.azurerm_user_assigned_identity.ingressid.principal_id 20 | } -------------------------------------------------------------------------------- /Azure/TerraformAKS/cosmosdb.tf: -------------------------------------------------------------------------------- 1 | resource "random_integer" "ri" { 2 | min = 10000 3 | max = 99999 4 | } 5 | resource "azurerm_cosmosdb_account" "db" { 6 | name = "bookmarkedhotels-${random_integer.ri.result}" 7 | location = azurerm_resource_group.aksresgroup.location 8 | resource_group_name = azurerm_resource_group.aksresgroup.name 9 | offer_type = "Standard" 10 | kind = "MongoDB" 11 | 12 | enable_automatic_failover = true 13 | 14 | capabilities { 15 | name = "EnableAggregationPipeline" 16 | } 17 | 18 | capabilities { 19 | name = "mongoEnableDocLevelTTL" 20 | } 21 | 22 | capabilities { 23 | name = "MongoDBv3.4" 24 | } 25 | 26 | capabilities { 27 | name = "EnableMongo" 28 | } 29 | 30 | consistency_policy { 31 | consistency_level = "BoundedStaleness" 32 | max_interval_in_seconds = 300 33 | max_staleness_prefix = 100000 34 | } 35 | 36 | geo_location { 37 | location = var.failover_location 38 | failover_priority = 1 39 | } 40 | 41 | geo_location { 42 | location = azurerm_resource_group.aksresgroup.location 43 | failover_priority = 0 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Azure/TerraformAKS/cosmosdb_output.tf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/Azure/TerraformAKS/cosmosdb_output.tf -------------------------------------------------------------------------------- /Azure/TerraformAKS/locals.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | virtual_network_cidr = "10.16.0.0/16" 3 | dns_ip = "10.16.0.10" 4 | api_gateway_cidr = cidrsubnet(local.virtual_network_cidr, 8, 20) 5 | subnets = { 6 | cidrs = [for i in range(0, var.subnet_count, 1) : cidrsubnet(local.virtual_network_cidr, 8, i)] 7 | names = [for i in range(0, var.subnet_count, 1) : join("-", ["subnet", i])] 8 | } 9 | } -------------------------------------------------------------------------------- /Azure/TerraformAKS/network.tf: -------------------------------------------------------------------------------- 1 | module "network" { 2 | source = "Azure/network/azurerm" 3 | resource_group_name = azurerm_resource_group.aksresgroup.name 4 | address_space = local.virtual_network_cidr 5 | subnet_prefixes = local.subnets.cidrs 6 | subnet_names = local.subnets.names 7 | depends_on = [azurerm_resource_group.aksresgroup] 8 | } 9 | -------------------------------------------------------------------------------- /Azure/TerraformAKS/providers.tf: -------------------------------------------------------------------------------- 1 | provider "azurerm" { 2 | features {} 3 | } 4 | 5 | terraform { 6 | 7 | 8 | required_providers { 9 | kubectl = { 10 | source = "gavinbunney/kubectl" 11 | version = ">= 1.7.0" 12 | } 13 | } 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /Azure/TerraformAKS/resourcegroup.tf: -------------------------------------------------------------------------------- 1 | resource "azurerm_resource_group" "aksresgroup" { 2 | name = "aks-resource-group" 3 | location = var.location 4 | } -------------------------------------------------------------------------------- /Azure/TerraformAKS/templates/external_dns_values.yaml.tmpl: -------------------------------------------------------------------------------- 1 | provider: azure 2 | azure: 3 | resourceGroup: ${resource_group} 4 | tenantId: ${tenant_id} 5 | subscriptionId: ${subscription_id} 6 | useManagedIdentityExtension: true 7 | userAssignedIdentityID: ${userAssignedIdentityID} 8 | logLevel: ${log_level} 9 | domainFilters: 10 | - ${domain} 11 | txtOwnerId: external-dns -------------------------------------------------------------------------------- /Azure/TerraformAKS/variables.tf: -------------------------------------------------------------------------------- 1 | 2 | variable "prefix" { 3 | description = "The prefix which should be used for all resources in this example" 4 | default = "hotelsearchservice" 5 | } 6 | 7 | variable "location" { 8 | description = "The Azure Region in which all resources in this example should be created." 9 | default = "eastus" 10 | } 11 | variable "subscription_id" { 12 | 13 | } 14 | variable "subnet_count" { 15 | default = 2 16 | } 17 | 18 | variable "dnszone_rg" { 19 | description = "Resource group of DNS Zone" 20 | } 21 | 22 | variable "failover_location" { 23 | default = "westus" 24 | } 25 | 26 | variable "dns_resource_group" { 27 | default = "azaks" 28 | description = "Resource group name of Azure DNS Hosted Zone" 29 | } 30 | variable "email_id" { 31 | 32 | } 33 | variable "domain_name" { 34 | 35 | description = "Registered Domain Name" 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/.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 -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/.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/azurerm" { 5 | version = "2.96.0" 6 | constraints = "~> 2.26" 7 | hashes = [ 8 | "h1:2nm+GD6yWznX+SATc9TdvXdxpRSgWVAhsu260Yfzvtw=", 9 | "zh:15ea84e6e223125fe733f50b7a3d46772f9d990e8b96ecdf9a649e6e222666e2", 10 | "zh:17c5a37d5a8e9fda3265ec26ef8d9a7625b70c51cc26635762aec1ff8542adb2", 11 | "zh:36f5367b55c882281a0b612e9b6efdfa49780991d335c2b0aa61497e3a41f1c9", 12 | "zh:6e8e29440f82b509d4231e15ed73ee3c35c759daeea8c7e6b227dce2e02c9b3b", 13 | "zh:73f5b54c99c24c14bf75d0c72c211d3a47c3d66d8ac8d60719d7dbd43c47a895", 14 | "zh:95c3e033a139d439c863745e949580eed4f2075f57c6c95d9ae2c30c6048163d", 15 | "zh:c7ce8e461b1813c65bb6aa268b2c7301c8bfd1e0fc25e1e42871d5be80e36838", 16 | "zh:d6544ad6fb14274b8b281319c737a571abcfd8b941d47f363f760868c3651acc", 17 | "zh:e90fd0d7615654f725ddef72698635b1a96703220d60a8fe5c50e76d03b37bef", 18 | "zh:e92ed224f4b2f2d95d46fb4270217ec1737d04998850fd191f032a30f1ff2eaa", 19 | "zh:ebfc2cc7005d83c6a405e9fa8ee241e68bda37f7686ed79782d347bde3d53222", 20 | ] 21 | } 22 | 23 | provider "registry.terraform.io/hashicorp/random" { 24 | version = "3.1.0" 25 | hashes = [ 26 | "h1:EPIax4Ftp2SNdB9pUfoSjxoueDoLc/Ck3EUoeX0Dvsg=", 27 | "zh:2bbb3339f0643b5daa07480ef4397bd23a79963cc364cdfbb4e86354cb7725bc", 28 | "zh:3cd456047805bf639fbf2c761b1848880ea703a054f76db51852008b11008626", 29 | "zh:4f251b0eda5bb5e3dc26ea4400dba200018213654b69b4a5f96abee815b4f5ff", 30 | "zh:7011332745ea061e517fe1319bd6c75054a314155cb2c1199a5b01fe1889a7e2", 31 | "zh:738ed82858317ccc246691c8b85995bc125ac3b4143043219bd0437adc56c992", 32 | "zh:7dbe52fac7bb21227acd7529b487511c91f4107db9cc4414f50d04ffc3cab427", 33 | "zh:a3a9251fb15f93e4cfc1789800fc2d7414bbc18944ad4c5c98f466e6477c42bc", 34 | "zh:a543ec1a3a8c20635cf374110bd2f87c07374cf2c50617eee2c669b3ceeeaa9f", 35 | "zh:d9ab41d556a48bd7059f0810cf020500635bfc696c9fc3adab5ea8915c1d886b", 36 | "zh:d9e13427a7d011dbd654e591b0337e6074eef8c3b9bb11b2e39eaaf257044fd7", 37 | "zh:f7605bd1437752114baf601bdf6931debe6dc6bfe3006eb7e9bb9080931dca8a", 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/apim.tf: -------------------------------------------------------------------------------- 1 | 2 | module "apim" { 3 | source = "./apim" 4 | prefix = var.prefix 5 | resource_group_name = azurerm_resource_group.rg.name 6 | resource_group_location = azurerm_resource_group.rg.location 7 | function_app_name = azurerm_function_app.functions.name 8 | publisher_email = var.publisher_email 9 | publisher_name = var.publisher_name 10 | host_name = azurerm_function_app.functions.default_hostname 11 | environment = var.environment 12 | api_paths = local.api_paths 13 | openid_url = var.openid_url 14 | depends_on = [ 15 | azurerm_function_app.functions 16 | ] 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/apim/output.tf: -------------------------------------------------------------------------------- 1 | output "func_keys" { 2 | //value = "${lookup(azurerm_template_deployment.azfn_function_key.outputs, "functionkey")}" 3 | value=azurerm_api_management_named_value.apim_prop_azfn_key.value 4 | } 5 | 6 | output "gateway_url" { 7 | value= replace(azurerm_api_management.bookingapi.developer_portal_url,"https://","") 8 | 9 | } 10 | 11 | output "id" { 12 | value= azurerm_api_management.bookingapi.id 13 | 14 | } 15 | 16 | output "name" { 17 | value= azurerm_api_management.bookingapi.name 18 | } 19 | 20 | output "principal_id"{ 21 | value =azurerm_api_management.bookingapi.identity[0].principal_id 22 | } -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/apim/variables.tf: -------------------------------------------------------------------------------- 1 | variable "prefix" { 2 | 3 | } 4 | variable "resource_group_name" { 5 | 6 | } 7 | variable "resource_group_location" { 8 | 9 | } 10 | 11 | variable "function_app_name"{ 12 | 13 | } 14 | variable "publisher_name"{ 15 | 16 | } 17 | variable "publisher_email"{ 18 | 19 | } 20 | 21 | variable "host_name"{ 22 | 23 | } 24 | variable "environment" { 25 | 26 | } 27 | variable "api_paths" { 28 | 29 | } 30 | variable "claim_name" { 31 | default="aud" 32 | 33 | } 34 | variable "claim_Value" { 35 | default="8338dac5-fa34-4477-a8fd-6b31299d8917" 36 | 37 | } 38 | variable "openid_url" { 39 | 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/apim_custom_domain/main.tf: -------------------------------------------------------------------------------- 1 | //https://github.com/hashicorp/terraform-provider-azurerm/issues/15256 2 | //resource "null_resource" "previous" {} 3 | 4 | data "azurerm_client_config" "current" {} 5 | 6 | data "azurerm_key_vault" "cert-keyvault" { 7 | name = var.keyvault_name 8 | resource_group_name = var.keyvault_resgroup_name 9 | } 10 | 11 | 12 | resource "azurerm_key_vault_access_policy" "apim_said" { 13 | key_vault_id = data.azurerm_key_vault.cert-keyvault.id 14 | object_id = var.apim_principal_id 15 | tenant_id = data.azurerm_client_config.current.tenant_id 16 | secret_permissions = [ 17 | "Get", 18 | "List" 19 | ] 20 | 21 | } 22 | 23 | 24 | 25 | /**resource "time_sleep" "wait_60_seconds" { 26 | depends_on = [azurerm_key_vault_access_policy.apim_said] 27 | 28 | create_duration = "60s" 29 | }*/ 30 | 31 | resource "azurerm_api_management_custom_domain" "apimcustomdomain" { 32 | api_management_id = var.apim_id 33 | 34 | proxy { 35 | host_name = var.host_name 36 | key_vault_id = var.cert_key_vault_secret_id 37 | } 38 | 39 | /*depends_on = [ 40 | time_sleep.wait_60_seconds 41 | ]*/ 42 | } 43 | 44 | 45 | data "azurerm_dns_zone" "dnszone" { 46 | name = var.dns_zone_name 47 | resource_group_name = var.dns_zone_rg 48 | } 49 | 50 | resource "azurerm_dns_cname_record" "cnamerecord" { 51 | name = var.prefix 52 | zone_name = data.azurerm_dns_zone.dnszone.name 53 | resource_group_name = data.azurerm_dns_zone.dnszone.resource_group_name 54 | ttl = 300 55 | record = var.apim_url 56 | } -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/apim_custom_domain/output.tf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/Azure/TerraformAzureAPIMFunctionApp/apim_custom_domain/output.tf -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/apim_custom_domain/variables.tf: -------------------------------------------------------------------------------- 1 | variable "dns_zone_name" { 2 | 3 | description = "DNS Name registered" 4 | type = string 5 | 6 | } 7 | variable "dns_zone_rg" { 8 | 9 | description = "Resurce group name of Azure DNS Hosted Zone" 10 | type = string 11 | 12 | } 13 | 14 | variable "keyvault_name" { 15 | description = "Key Vault name where certificate is uploaded" 16 | type = string 17 | 18 | 19 | } 20 | variable "keyvault_resgroup_name" { 21 | description = "" 22 | type = string 23 | } 24 | 25 | variable "cert_key_vault_secret_id" { 26 | 27 | type = string 28 | 29 | } 30 | 31 | variable "host_name" { 32 | 33 | description = "Custom Domain for APIM" 34 | type = string 35 | } 36 | 37 | variable "apim_id"{ 38 | type = string 39 | 40 | } 41 | variable "apim_url"{ 42 | type = string 43 | 44 | } 45 | variable "apim_principal_id" { 46 | type = string 47 | 48 | } 49 | variable "prefix" { 50 | type = string 51 | 52 | } -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/apim_insights.tf: -------------------------------------------------------------------------------- 1 | resource "azurerm_application_insights" "ai" { 2 | name = "${var.prefix}appinsights" 3 | resource_group_name = azurerm_resource_group.rg.name 4 | location = azurerm_resource_group.rg.location 5 | application_type = "web" 6 | 7 | } 8 | # Create Logger 9 | resource "azurerm_api_management_logger" "apimLogger" { 10 | name = "${var.prefix}-logger" 11 | api_management_name = module.apim.name 12 | resource_group_name = azurerm_resource_group.rg.name 13 | 14 | application_insights { 15 | instrumentation_key = azurerm_application_insights.ai.instrumentation_key 16 | } 17 | } -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/custom_domain.tf: -------------------------------------------------------------------------------- 1 | //https://github.com/hashicorp/terraform-provider-azurerm/issues/15256 2 | //resource "null_resource" "previous" {} 3 | 4 | module "custom_domain_apim" { 5 | 6 | source = "./apim_custom_domain" 7 | apim_id = module.apim.id 8 | apim_url = module.apim.gateway_url 9 | keyvault_name = var.keyvault_name 10 | keyvault_resgroup_name = var.keyvault_resgroup_name 11 | apim_principal_id = module.apim.principal_id 12 | host_name = var.host_name 13 | dns_zone_name = var.dns_zone_name 14 | dns_zone_rg = var.dns_zone_rg 15 | cert_key_vault_secret_id = var.cert_key_vault_secret_id 16 | prefix =var.prefix 17 | 18 | 19 | 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/functioncode/Functions.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/Azure/TerraformAzureAPIMFunctionApp/functioncode/Functions.zip -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/lambda_functions.tf: -------------------------------------------------------------------------------- 1 | resource "azurerm_function_app" "functions" { 2 | name = "${var.prefix}-${var.environment}" 3 | location = var.location 4 | resource_group_name = azurerm_resource_group.rg.name 5 | app_service_plan_id = azurerm_app_service_plan.asp.id 6 | storage_account_access_key = azurerm_storage_account.storage.primary_access_key 7 | storage_account_name = azurerm_storage_account.storage.name 8 | version = "~3" 9 | 10 | app_settings = { 11 | https_only = true 12 | FUNCTIONS_EXTENSION_VERSION = "~3" 13 | rapidapikey = var.rapidapi_key 14 | MONGODB_URL = var.mongodb_url 15 | MONGODB_DATABASE_NAME = var.mongodb_name 16 | MONGODB_COLLECTION_NAME = var.mongodb_container_name 17 | FUNCTIONS_WORKER_RUNTIME = "node" 18 | WEBSITE_CONTENTAZUREFILECONNECTIONSTRING = "${azurerm_storage_account.storage.primary_connection_string}" 19 | WEBSITE_CONTENTSHARE = "${azurerm_storage_account.storage.name}" 20 | HASH = "${base64encode(filesha256("${path.module}/functioncode/Functions.zip"))}" 21 | WEBSITE_NODE_DEFAULT_VERSION = "~14" 22 | WEBSITE_RUN_FROM_PACKAGE = "https://${azurerm_storage_account.storage.name}.blob.core.windows.net/${azurerm_storage_container.deployments.name}/${azurerm_storage_blob.appcode.name}${data.azurerm_storage_account_sas.example.sas}" 23 | } 24 | } 25 | 26 | output "fnhost" { 27 | value = azurerm_function_app.functions.default_hostname 28 | 29 | } -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/locals.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | api_paths = [ 3 | { 4 | url_path = "/HotelLocations" 5 | operation_id = "get-hotel-location" 6 | method = "GET" 7 | description = "Get list of locations" 8 | jwtAuth = true 9 | }, { 10 | url_path = "/Hotels" 11 | operation_id = "get-hotels" 12 | method = "GET" 13 | description = "Get list of hotels" 14 | jwtAuth = false 15 | }, { 16 | url_path = "/HotelReviews" 17 | operation_id = "get-reviews" 18 | method = "GET" 19 | description = "Get list of reviews for the hotel" 20 | jwtAuth = false 21 | }, { 22 | url_path = "/HotelPhotos" 23 | operation_id = "get-photos" 24 | method = "GET" 25 | description = "Get list of photos for the hotel" 26 | jwtAuth = false 27 | }, { 28 | url_path = "/HotelFacilities" 29 | operation_id = "get-facilities" 30 | method = "GET" 31 | description = "Get list of Facilities for the selected hotel" 32 | jwtAuth = false 33 | }, 34 | { 35 | url_path = "/HotelDescription" 36 | operation_id = "get-description" 37 | method = "GET" 38 | description = "Get hotel Description" 39 | jwtAuth = false 40 | }, 41 | { 42 | url_path = "/FavoriteHotels" 43 | operation_id = "get-favhotels" 44 | method = "GET" 45 | description = "Get Bookmarked Props" 46 | jwtAuth = false 47 | }, 48 | { 49 | url_path = "/FavoriteHotels" 50 | operation_id = "post-favhotels" 51 | method = "POST" 52 | description = "Bookmark a property" 53 | jwtAuth = false 54 | } 55 | ] 56 | 57 | 58 | } -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/output.tf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/Azure/TerraformAzureAPIMFunctionApp/output.tf -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/provider.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_providers { 3 | azurerm = { 4 | source = "hashicorp/azurerm" 5 | # Root module should specify the maximum provider version 6 | # The ~> operator is a convenient shorthand for allowing only patch releases within a specific minor release. 7 | version = "~> 2.26" 8 | } 9 | } 10 | } 11 | 12 | provider "azurerm" { 13 | features {} 14 | } 15 | -------------------------------------------------------------------------------- /Azure/TerraformAzureAPIMFunctionApp/storage_accounts.tf: -------------------------------------------------------------------------------- 1 | resource "azurerm_storage_account" "storage" { 2 | name = random_string.storage_name.result 3 | resource_group_name = azurerm_resource_group.rg.name 4 | location = var.location 5 | account_tier = "Standard" 6 | account_replication_type = "LRS" 7 | } 8 | 9 | resource "azurerm_storage_container" "deployments" { 10 | name = "function-releases" 11 | storage_account_name = azurerm_storage_account.storage.name 12 | container_access_type = "private" 13 | } 14 | 15 | resource "azurerm_storage_blob" "appcode" { 16 | name = "Functions.zip" 17 | storage_account_name = azurerm_storage_account.storage.name 18 | storage_container_name = azurerm_storage_container.deployments.name 19 | type = "Block" 20 | source = "${path.module}/functioncode/Functions.zip" 21 | } 22 | 23 | data "azurerm_storage_account_sas" "example" { 24 | connection_string = azurerm_storage_account.storage.primary_connection_string 25 | https_only = true 26 | signed_version = "2017-07-29" 27 | 28 | resource_types { 29 | service = true 30 | container = true 31 | object = true 32 | } 33 | 34 | services { 35 | blob = true 36 | queue = false 37 | table = false 38 | file = false 39 | } 40 | 41 | start = "2022-02-13T00:00:00Z" 42 | expiry = "2022-03-31T00:00:00Z" 43 | 44 | permissions { 45 | read = true 46 | write = true 47 | delete = false 48 | list = false 49 | add = true 50 | create = true 51 | update = false 52 | process = false 53 | } 54 | } 55 | 56 | resource "azurerm_app_service_plan" "asp" { 57 | name = "${var.prefix}-plan" 58 | resource_group_name = azurerm_resource_group.rg.name 59 | location = var.location 60 | kind = "FunctionApp" 61 | sku { 62 | tier = "Dynamic" 63 | size = "Y1" 64 | } 65 | } -------------------------------------------------------------------------------- /Azure/TerraformCDN/.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 -------------------------------------------------------------------------------- /Azure/TerraformCDN/README.md: -------------------------------------------------------------------------------- 1 | This project creates azure blob storage configured for static website, Azure CDN profile, endpoint and enables custom domain along with SSL/TLS certificate 2 | 3 | Create terraform.tfvars with the following entries: 4 | 5 | dnszone_rg= Resource group of DNS Zone 6 | 7 | custom_domain_name= Name of the subdomain 8 | 9 | domain_name= Registered Domain Name 10 | -------------------------------------------------------------------------------- /Azure/TerraformCDN/customscript.ps1: -------------------------------------------------------------------------------- 1 | Connect-AzAccount 2 | New-AzADServicePrincipal -ApplicationId "205478c0-bd83-4e1b-a9d6-db63a3e1e1c8" 3 | -------------------------------------------------------------------------------- /Azure/TerraformCDN/outputscript.ps1: -------------------------------------------------------------------------------- 1 | Connect-AzAccount 2 | $PrincipalId= $(Get-AzureADServicePrincipal -Filter "AppId eq '205478c0-bd83-4e1b-a9d6-db63a3e1e1c8'").ObjectId 3 | Write-Output "{ ""PrincipalId"" : ""$PrincipalId""}" -------------------------------------------------------------------------------- /Azure/TerraformCDN/providers.tf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/Azure/TerraformCDN/providers.tf -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/.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 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "travelpocfrontend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.2", 7 | "@testing-library/react": "^12.1.2", 8 | "@testing-library/user-event": "^13.5.0", 9 | "@azure/msal-browser": "^2.15.0", 10 | "@azure/msal-react": "^1.0.1", 11 | "@emotion/react": "^11.7.0", 12 | "@emotion/styled": "^11.6.0", 13 | "@mui/icons-material": "^5.2.1", 14 | "@mui/lab": "^5.0.0-alpha.59", 15 | "@mui/material": "^5.2.2", 16 | "@mui/styled-engine-sc": "^5.1.0", 17 | "@reduxjs/toolkit": "^1.7.1", 18 | "amazon-cognito-identity-js": "^5.2.4", 19 | "currency-symbol-map": "^5.0.1", 20 | "date-fns": "^2.27.0", 21 | "dateformat": "^5.0.2", 22 | "html-react-parser": "^1.4.4", 23 | "react": "^17.0.2", 24 | "react-dom": "^17.0.2", 25 | "react-scripts": "5.0.0", 26 | "react-redux": "^7.2.6", 27 | "react-router-dom": "^6.2.1", 28 | "react-slick": "^0.28.1", 29 | "slick-carousel": "^1.8.1", 30 | "styled-components": "^5.3.3", 31 | "web-vitals": "^2.1.4" 32 | }, 33 | "scripts": { 34 | "start": "react-scripts start", 35 | "build": "react-scripts build", 36 | "test": "react-scripts test", 37 | "eject": "react-scripts eject" 38 | }, 39 | "eslintConfig": { 40 | "extends": [ 41 | "react-app", 42 | "react-app/jest" 43 | ] 44 | }, 45 | "browserslist": { 46 | "production": [ 47 | ">0.2%", 48 | "not dead", 49 | "not op_mini all" 50 | ], 51 | "development": [ 52 | "last 1 chrome version", 53 | "last 1 firefox version", 54 | "last 1 safari version" 55 | ] 56 | }, 57 | "devDependencies": { 58 | "sass": "^1.44.0", 59 | "sass-loader": "^12.4.0" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/Azure/TravelPOCFrontend/public/favicon.ico -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/Azure/TravelPOCFrontend/public/logo192.png -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-pavithraa/CloudMiniProjects/08b6e5ccd01e57fac0ba813e2380ee3622def10b/Azure/TravelPOCFrontend/public/logo512.png -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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; -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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; -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 | if(bookmarkedProps && bookmarkedProps.hotelsList){ 27 | const elem=bookmarkedProps.hotelsList.find(x=>x.hotelId===props.hotelId); 28 | if(elem!==undefined) 29 | setFavorite(true); 30 | } 31 | 32 | 33 | },[]) 34 | 35 | const addToFavHandler = ()=>{ 36 | if(authCtx.isLoggedIn){ 37 | 38 | if (authCtx.reqHeader !== null && authCtx.reqHeader !== undefined) { 39 | 40 | dispatch(postBookmarkHotel(authCtx.reqHeader, authCtx.userName,props.hotelId)); 41 | } 42 | }else{ 43 | alert('Please login'); 44 | } 45 | 46 | } 47 | return ( 48 | 49 | 50 | 51 | {props.name} 52 | 53 | 54 | 55 | 56 | {isFavorite?:} 57 | 58 | ); 59 | } 60 | 61 | export default HotelTopBar; -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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; -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 | } -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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; -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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; -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 | } -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 | import { PublicClientApplication } from "@azure/msal-browser"; 11 | import { MsalProvider } from "@azure/msal-react"; 12 | import { msalConfig } from "./util/authConfig"; 13 | const msalInstance = new PublicClientApplication(msalConfig); 14 | 15 | ReactDOM.render( 16 | 17 | 18 | 19 | 20 | 21 | , 22 | document.getElementById('root') 23 | ); 24 | 25 | // If you want to start measuring performance in your app, pass a function 26 | // to log results (for example: reportWebVitals(console.log)) 27 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 28 | reportWebVitals(); 29 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/src/pages/FavoriteHotels.js: -------------------------------------------------------------------------------- 1 | import SavedHotel from "../components/hotel/SavedHotel" 2 | 3 | const FavoriteHotels = ()=>{ 4 | return 5 | } -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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; -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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; -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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; -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/src/util/Constants.js: -------------------------------------------------------------------------------- 1 | export const SERVICE_API_URL = 'http://localhost:8102/'; 2 | 3 | export const REVERSE_GEO_API='https://api.bigdatacloud.net/data/reverse-geocode-client?latitude=37.42159&longitude=-122.0837&localityLanguage=en' 4 | ////Key has to be added https://www.bigdatacloud.com/ 5 | export const LOCATION_API='https://api.bigdatacloud.net/data/ip-geolocation?key=9509b82187044d29a9d0134ceb037f05' 6 | // Backend Serice URL 7 | export const TRAVEL_SERVICE_API_URL = 'https://bookingserviceapi.saaralkaatru.com/bookingserviceapi-prod/'; 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 | 12 | //B2C Constants 13 | 14 | export const B2C_CLIENT_ID="8338dac5-fa34-4477-a8fd-6b31299d8917"; 15 | //User Flow 16 | export const B2C_AUTHORITY="https://pocorgb2c.b2clogin.com/pocorgb2c.onmicrosoft.com/B2C_1_todo2101"; 17 | //Have to be configured in App Registration -> App ->Authentication 18 | export const REDIRECT_URI = "http://localhost:3000"; 19 | export const LOGOUT_URI="http://localhost:3000/"; 20 | export const KNOWN_AUTHORITIES = "pocorgb2c.b2clogin.com"; 21 | export const READ_SCOPE = "https://pocorgb2c.onmicrosoft.com/f0753138-0486-4581-9c50-2f129b923d9c/User.Read" -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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 | -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/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)); -------------------------------------------------------------------------------- /Azure/TravelPOCFrontend/src/util/authConfig.js: -------------------------------------------------------------------------------- 1 | import { B2C_AUTHORITY, B2C_CLIENT_ID, KNOWN_AUTHORITIES, LOGOUT_URI, READ_SCOPE, REDIRECT_URI } from "./Constants"; 2 | 3 | export const msalConfig = { 4 | auth: { 5 | clientId: B2C_CLIENT_ID, 6 | authority: B2C_AUTHORITY, 7 | redirectUri: REDIRECT_URI, 8 | knownAuthorities: [KNOWN_AUTHORITIES], 9 | postLogoutRedirectUri: LOGOUT_URI 10 | 11 | }, 12 | cache: { 13 | cacheLocation: "sessionStorage", 14 | storeAuthStateInCookie: false, 15 | } 16 | }; 17 | 18 | 19 | 20 | // Add scopes here for ID token to be used at Microsoft identity platform endpoints. 21 | export const loginRequest = { 22 | scopes: [READ_SCOPE] 23 | }; 24 | 25 | // Add the endpoints here for Microsoft Graph API services you'd like to use. 26 | export const graphConfig = { 27 | graphMeEndpoint: "https://graph.microsoft.com/v1.0/me" 28 | }; --------------------------------------------------------------------------------