{"id":21015528,"url":"https://github.com/ericogr/go-counter-online","last_synced_at":"2026-04-17T01:02:41.220Z","repository":{"id":44596879,"uuid":"442274216","full_name":"ericogr/go-counter-online","owner":"ericogr","description":"All in one repository to build and deploy an application to AWS provider.","archived":false,"fork":false,"pushed_at":"2022-02-25T00:33:49.000Z","size":351,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T16:45:40.076Z","etag":null,"topics":["aws","git","gitactions","kubernetes","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericogr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-27T21:10:22.000Z","updated_at":"2024-02-05T20:13:24.000Z","dependencies_parsed_at":"2022-09-03T07:11:50.909Z","dependency_job_id":null,"html_url":"https://github.com/ericogr/go-counter-online","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ericogr/go-counter-online","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericogr%2Fgo-counter-online","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericogr%2Fgo-counter-online/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericogr%2Fgo-counter-online/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericogr%2Fgo-counter-online/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericogr","download_url":"https://codeload.github.com/ericogr/go-counter-online/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericogr%2Fgo-counter-online/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31910584,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"ssl_error","status_checked_at":"2026-04-16T18:21:47.142Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","git","gitactions","kubernetes","terraform"],"created_at":"2024-11-19T10:10:15.289Z","updated_at":"2026-04-17T01:02:41.194Z","avatar_url":"https://github.com/ericogr.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Counter Online\n\nCounter Online is just my learning project to experiment some technologies. Here you will find:\n\n- Backend app written in Go language (using [GO kit](http://gokit.io/))\n- Terraform to deploy infrastructure components on AWS\n- Kubernetes to manage app containers\n- GitHub Actions to CI/CD\n- AWS as a cloud provider\n\n# Introduction\nImagine following scenario: sellers wants to keep their product authenticity and users want to check it to get quality goods. You can provide together their product a unique identifier to be validated online. When user validate it for the first time, the counter is one. This means that no one else validated the code before and it can be considered authentic. If another manufacturer makes a copy and sell it as original, they need to give the validation code to customers. If customers tries to validate, the code can be already used or invalid.\n\n# Development state\n|Feature|Description|State|Comment|\n|-------|-----------|-----|-------|\n|Documentation|Document the process and architecture|In progress|-|\n|Counter App Service|The counter application|Ready|-|\n|Counter App Service|Use GO kit to create services|Ready|-|\n|Counter App Service Build|The counter continuous integration (CI)|Ready|-|\n|Counter App Service Deployment|The counter application deployment (CD)|Ready|-|\n|AWS Infrastructure (Terraform)|Terraform files to create infrastructure|Ready|-|\n|AWS Infrastructure (Terraform) Deployment|Terraform infrastructure pipeline (CD)|Ready|-|\n|AWS Password Manager CSI Driver|CSI driver deployment|Ready|-|\n|AWS Password Manager CSI Provider|CSI provider deployment|Ready|-|\n|AWS Kubernetes Cluster Autoscaler|Automatically adjusts the number of nodes when needed|Ready|-|\n|AWS Kubernetes Cluster Autoscaler Deployment|AWS Kubernetes Cluster Autoscaler pipeline|Ready|-|\n|Ingress Nginx|Kubernetes ingress deployment|Ready|-|\n|DNS Management|Implement DNS Management|Not started|-|\n|CertManager|Implement Cert Manager|Not started|-|\n\n# Folders\nThis project is organized as follows:\n\n![project-folder-structure](docs/images/project-folder-structure.png?raw=true)\n\n|Folder|Description|\n|:-----|:----------|\n|.github/workflows|GitHub action workflow pipelines|\n|app|App source code in GO Language|\n|terraform|Terraform HCL files to deploy infrastructure|\n|deployments|Kubernetes Deployment folders to create basic infrastructure software elements like ingress|\n|scripts|Scripts used help to prepare terraform infrastructure, creating aws user, policies, s3, etc|\n\n\u003e **_IMPORTANT:_** In a production environment, you must use different repositories to each component (application, kubernetes deployments, terraform...)\n\n# Architecture\n## Workflow\n\nThis is the use case for this project. Here we have the seller creating UUID v5 codes to be validated by the customer (maybe using qr code), as you saw in the beginning of this document.\n\n![app-flow](docs/images/app-flow.png?raw=true)\n\n## Infrastructure Architecture\nAbove you will find the application architecture. I used AWS provider and terraform to deploy infrastructure components.\n\n![app-architecture](docs/images/project-architecture.png?raw=true)\n\n# How to use this repository\nI recommend you fork this repository and change it to use your own parameters. The next two sections, I'll show you what you gonna need to do.\n\n## GitHub Actions secret variables\nThese are GitHub Action variables needed by automation. Please, create these key-values inside your github repository:\n\n|Variable Name|Description|\n|-------------|-----------|\n|AWS_SECRET_ACCESS_KEY|Store your AWS provider access key|\n|AWS_ACCESS_KEY_ID|Store your AWS provider secret key|\n|AWS_DEFAULT_REGION|Your AWS provider Region|\n|TERRAFORM_GITHUB_TOKEN|Create a GitHub [PAT](https://docs.github.com/pt/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) (default token [doesn't work](https://github.community/t/are-there-plans-to-allow-the-actions-token-to-modify-secrets/17626)]|\n\n## AWS Credenciais and Terraform resources\nThis project is using Terraform to maintain the infrastructure. You need to configure credentials, permissions and storage to maintain state. You can use the ```scripts/startup-terraform-backend-state.sh``` script to help you.\n\n## Account configuration\nSome files have AWS account ID hardcoded. You can replace these values with your AWS account id using `find ./ -type f -exec sed -i 's/043934856969/100000000001/g' {} \\;` where 100000000001 is your aws acccount id.\n\n### If you want to change every file manually or check each configuration, here is the list\n\nOpen file **go-counter-online/deployments/kustomize/common/base/service-account.yaml** and change:\n```yaml\neks.amazonaws.com/role-arn: arn:aws:iam::043934856969:role/AmazonSCPRole\n```\nto\n```yaml\neks.amazonaws.com/role-arn: arn:aws:iam::\u003cyour aws account id\u003e:role/AmazonSCPRole\n```\n\nOpen file **go-counter-online/deployments/specs/aws-cluster-autoscaler-service/cluster-autoscaler-autodiscover.yaml** and change:\n```yaml\neks.amazonaws.com/role-arn\": \"arn:aws:iam::043934856969:role/AmazonEKSClusterAutoscalerRole\n```\nto\n```yaml\neks.amazonaws.com/role-arn\": \"arn:aws:iam::\u003cyour aws account id\u003e:role/AmazonEKSClusterAutoscalerRole\n```\n\nOpen file **go-counter-online/deployments/specs/aws-load-balancer-controler-service/aws-load-balancer-controller-service-account.yaml** and change:\n```yaml\neks.amazonaws.com/role-arn: arn:aws:iam::043934856969:role/AmazonEKSLoadBalancerControllerRole\n```\nto\n```yaml\neks.amazonaws.com/role-arn: arn:aws:iam::\u003cyour aws account id\u003e:role/AmazonEKSLoadBalancerControllerRole\n```\n\nOpen file **go-counter-online/deployments/specs/aws-load-balancer-controler-service/aws-load-balancer-controller-service-account.yaml** and change:\n```yaml\neks.amazonaws.com/role-arn: arn:aws:iam::043934856969:role/AmazonEKSLoadBalancerControllerRole\n```\nto\n```yaml\neks.amazonaws.com/role-arn: arn:aws:iam::\u003cyour aws account id\u003e:role/AmazonEKSLoadBalancerControllerRole\n```\n\nOpen file **go-counter-online/terraform/iam.tf** and change:\n```yaml\n\"Resource\": [\"arn:aws:secretsmanager:us-east-2:043934856969:secret:*\"]\n```\nto\n```yaml\n\"Resource\": [\"arn:aws:secretsmanager:us-east-2:\u003cyour aws account id\u003e:secret:*\"]\n```\n\n# Miscellaneous\n\n## Useful commands\n\n**Update kubeconfig to access EKS Cluster:**\n\n```sh\naws eks update-kubeconfig --name prd-go-counter-online-eks\n```\n\n**Docker build to test local:**\n```sh\ndocker build -t go-counter-online -f app/Dockerfile app\n```\n\n**Add users and roles to access the cluster:**\n\n```sh\nkubectl -n kube-system edit configmap aws-auth\n\n# Add user test like this:\n# 043934856969 is your account code\ndata:\n  (... other stuffs)\n  mapUsers: |\n    - userarn: arn:aws:iam::043934856969:user/test\n      username: test\n      groups:\n      - system:masters\n```\n\n**Command line to run Counter Online local**\n\n```sh\n# memory database\ngo run . -port=8080 -datastore=memory\n\n# or postgresql database\ngo run . -port=8080 -datastore=postgresql -extra-params='host=localhost dbname=go_counter_online user=go_counter_online password=go_counter_online_password sslmode=disable' -hide-extra-params=true\n```\n\n**Curl commands to test Counter Online API services**\n\n```sh\n# Create counter with UUID v5 AAAAAAAA-AAAA-5AAA-AAAA-AAAAAAAAAAAA using name test:\ncurl -v -XPOST localhost:8080/count/AAAAAAAA-AAAA-5AAA-AAAA-AAAAAAAAAAAA/test\n\n# Consume counter with UUID v5 AAAAAAAA-AAAA-5AAA-AAAA-AAAAAAAAAAAA:\ncurl -v -XGET localhost:8080/count/AAAAAAAA-AAAA-5AAA-AAAA-AAAAAAAAAAAA\n```\n\n**Deploy PSQL to test database**\n\nUse psql utility to connect to Postgres database:\n\n```sh\n#docker\ndocker run -it --rm postgres psql -h \u003cdbhost\u003e -U go_counter_online -d go_counter_online\n```\n\n```sh\n#kubernetes\nkubectl run psql --rm -it --image=postgres -- psql -h \u003cdbhost\u003e -U go_counter_online -d go_counter_online\n```\n\n## Links\n\n### Configure AWS EKS Kubernetes Cluster Autoscaler\nAutoscaling is a function that automatically scales your resources up or down to meet changing demands. This is a major Kubernetes function that would otherwise require extensive human resources to perform manually.\n\nMore info: https://docs.aws.amazon.com/eks/latest/userguide/autoscaling.html\n\n### Kubernetes Ingress Nginx\nIngress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster. Traffic routing is controlled by rules defined on the Ingress resource.\n\nMore info: https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.0/deploy/static/provider/aws/deploy.yaml","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericogr%2Fgo-counter-online","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericogr%2Fgo-counter-online","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericogr%2Fgo-counter-online/lists"}