aws-samples / eks-workshop-v2

Hands-on labs for Amazon EKS
https://www.eksworkshop.com
Apache License 2.0
432 stars 435 forks source link

Add cost estimation #312

Open svennam92 opened 1 year ago

svennam92 commented 1 year ago

What would you like to be added?

We should provide a blurb saying how much the lab environment costs to run, something like:

Cost to complete: This workshop will cost you less than $XX for 3 hours.*

*This estimate assumes you follow the recommended configurations throughout the tutorial and terminate all resources immediately after you complete the tutorial.

Why is this needed?

Users should know the expense of the Terraform they are deploying ahead of time.

niallthomson commented 1 year ago

We should also make sure to call out this is the "base cost" and call out modules that provision additional resources such as load balancers and the ACK/Crossplane labs which add extra RDS databases.

huytn1219 commented 1 year ago

I think we could use Infracost for Terraform tool to run a breakdown on our Terraform code.

I ran a preliminary analysis earlier and here is what I got


Name                                                                                                                                                    Monthly Qty  Unit                        Monthly Cost 

 module.cluster.aws_dynamodb_table.carts                                                                                                                                                                       
 ├─ Write request unit (WRU)                                                                                                                     Monthly cost depends on usage: $0.00000125 per WRUs           
 ├─ Read request unit (RRU)                                                                                                                      Monthly cost depends on usage: $0.00000025 per RRUs           
 ├─ Data storage                                                                                                                                 Monthly cost depends on usage: $0.25 per GB                   
 ├─ Point-In-Time Recovery (PITR) backup storage                                                                                                 Monthly cost depends on usage: $0.20 per GB                   
 ├─ On-demand backup storage                                                                                                                     Monthly cost depends on usage: $0.10 per GB                   
 ├─ Table data restored                                                                                                                          Monthly cost depends on usage: $0.15 per GB                   
 └─ Streams read request unit (sRRU)                                                                                                             Monthly cost depends on usage: $0.0000002 per sRRUs           

 module.cluster.aws_efs_file_system.efsassets                                                                                                                                                                  
 └─ Storage (standard)                                                                                                                           Monthly cost depends on usage: $0.30 per GB                   

 module.cluster.aws_kms_key.cmk                                                                                                                                                                                
 ├─ Customer master key                                                                                                                                            1  months                             $1.00 
 ├─ Requests                                                                                                                                     Monthly cost depends on usage: $0.03 per 10k requests         
 ├─ ECC GenerateDataKeyPair requests                                                                                                             Monthly cost depends on usage: $0.10 per 10k requests         
 └─ RSA GenerateDataKeyPair requests                                                                                                             Monthly cost depends on usage: $0.10 per 10k requests         

 module.cluster.module.aws_vpc.aws_eip.nat[0]                                                                                                                                                                  
 └─ IP address (if unused)                                                                                                                                       730  hours                              $3.65 

 module.cluster.module.aws_vpc.aws_nat_gateway.this[0]                                                                                                                                                         
 ├─ NAT gateway                                                                                                                                                  730  hours                             $32.85 
 └─ Data processed                                                                                                                               Monthly cost depends on usage: $0.045 per GB                  

 module.cluster.module.catalog_mysql.module.db_instance.aws_db_instance.this[0]                                                                                                                                
 ├─ Database instance (on-demand, Single-AZ, db.t4g.micro)                                                                                                       730  hours                             $11.68 
 └─ Storage (general purpose SSD, gp2)                                                                                                                            20  GB                                 $2.30 

 module.cluster.module.eks_blueprints.module.aws_eks.aws_eks_cluster.this[0]                                                                                                                                   
 └─ EKS cluster                                                                                                                                                  730  hours                             $73.00 

 module.cluster.module.eks_blueprints.module.aws_eks_fargate_profiles["checkout_profile"].aws_eks_fargate_profile.eks_fargate                                                                                  
 ├─ Per GB per hour                                                                                                                                                1  GB                                 $3.24 
 └─ Per vCPU per hour                                                                                                                                              1  CPU                               $29.55 

 module.cluster.module.eks_blueprints.module.aws_eks_managed_node_groups["mg_5"].aws_eks_node_group.managed_ng                                                                                                 
 ├─ Instance usage (Linux/UNIX, on-demand, m5.large)                                                                                                           1,460  hours                            $140.16 
 └─ Storage (general purpose SSD, gp2)                                                                                                                           100  GB                                $10.00 

 module.cluster.module.eks_blueprints.module.aws_eks_managed_node_groups["system"].aws_eks_node_group.managed_ng                                                                                               
 ├─ Instance usage (Linux/UNIX, on-demand, m5.large)                                                                                                             730  hours                             $70.08 
 └─ Storage (general purpose SSD, gp2)                                                                                                                            50  GB                                 $5.00 

 module.cluster.module.eks_blueprints.module.kms[0].aws_kms_key.this                                                                                                                                           
 ├─ Customer master key                                                                                                                                            1  months                             $1.00 
 ├─ Requests                                                                                                                                     Monthly cost depends on usage: $0.03 per 10k requests         
 ├─ ECC GenerateDataKeyPair requests                                                                                                             Monthly cost depends on usage: $0.10 per 10k requests         
 └─ RSA GenerateDataKeyPair requests                                                                                                             Monthly cost depends on usage: $0.10 per 10k requests         

 module.cluster.module.eks_blueprints_kubernetes_addons.module.aws_for_fluent_bit[0].aws_cloudwatch_log_group.aws_for_fluent_bit[0]                                                                            
 ├─ Data ingested                                                                                                                                Monthly cost depends on usage: $0.50 per GB                   
 ├─ Archival Storage                                                                                                                             Monthly cost depends on usage: $0.03 per GB                   
 └─ Insights queries data scanned                                                                                                                Monthly cost depends on usage: $0.005 per GB                  

 module.cluster.module.eks_blueprints_kubernetes_addons.module.aws_for_fluent_bit[0].module.kms[0].aws_kms_key.this                                                                                            
 ├─ Customer master key                                                                                                                                            1  months                             $1.00 
 ├─ Requests                                                                                                                                     Monthly cost depends on usage: $0.03 per 10k requests         
 ├─ ECC GenerateDataKeyPair requests                                                                                                             Monthly cost depends on usage: $0.10 per 10k requests         
 └─ RSA GenerateDataKeyPair requests                                                                                                             Monthly cost depends on usage: $0.10 per 10k requests         

 module.cluster.module.eks_blueprints_kubernetes_addons.module.aws_node_termination_handler[0].aws_sqs_queue.aws_node_termination_handler_queue                                                                
 └─ Requests                                                                                                                                     Monthly cost depends on usage: $0.40 per 1M requests          

 module.ide.module.cloud9_bootstrap_lambda.aws_cloudwatch_log_group.lambda[0]                                                                                                                                  
 ├─ Data ingested                                                                                                                                Monthly cost depends on usage: $0.50 per GB                   
 ├─ Archival Storage                                                                                                                             Monthly cost depends on usage: $0.03 per GB                   
 └─ Insights queries data scanned                                                                                                                Monthly cost depends on usage: $0.005 per GB                  

 module.ide.module.cloud9_bootstrap_lambda.aws_lambda_function.this[0]                                                                                                                                         
 ├─ Requests                                                                                                                                     Monthly cost depends on usage: $0.20 per 1M requests          
 ├─ Ephemeral storage                                                                                                                            Monthly cost depends on usage: $0.0000000309 per GB-seconds   
 └─ Duration (first 6B)                                                                                                                          Monthly cost depends on usage: $0.0000166667 per GB-seconds   

 OVERALL TOTAL                                                                                                                                                                                         $384.52 
──────────────────────────────────
175 cloud resources were detected:
∙ 17 were estimated, 11 of which include usage-based costs, see https://infracost.io/usage-file
∙ 151 were free:
  ∙ 39 x aws_iam_role_policy_attachment
  ∙ 23 x aws_iam_role
  ∙ 22 x aws_security_group_rule
  ∙ 18 x aws_iam_policy
  ∙ 5 x aws_security_group
  ∙ 4 x aws_cloudwatch_event_rule
  ∙ 4 x aws_cloudwatch_event_target
  ∙ 4 x aws_iam_instance_profile
  ∙ 4 x aws_network_acl_rule
  ∙ 3 x aws_kms_alias
  ∙ 3 x aws_route
  ∙ 2 x aws_ec2_tag
  ∙ 2 x aws_network_acl
  ∙ 2 x aws_route_table
  ∙ 2 x aws_route_table_association
  ∙ 2 x aws_subnet
  ∙ 1 x aws_db_subnet_group
  ∙ 1 x aws_efs_mount_target
  ∙ 1 x aws_egress_only_internet_gateway
  ∙ 1 x aws_iam_openid_connect_provider
  ∙ 1 x aws_iam_user
  ∙ 1 x aws_iam_user_policy_attachment
  ∙ 1 x aws_iam_user_ssh_key
  ∙ 1 x aws_internet_gateway
  ∙ 1 x aws_sqs_queue_policy
  ∙ 1 x aws_ssm_parameter
  ∙ 1 x aws_vpc
  ∙ 1 x aws_vpc_ipv4_cidr_block_association
∙ 7 are not supported yet, see https://infracost.io/requested-resources:
  ∙ 2 x aws_eks_addon
  ∙ 1 x aws_cloud9_environment_ec2
  ∙ 1 x aws_codecommit_repository
  ∙ 1 x aws_lambda_invocation
  ∙ 1 x aws_prometheus_workspace
  ∙ 1 x aws_ssm_document
huytn1219 commented 1 year ago

For the LBs in the cluster, we could refer to Kubecost and add the incurred cost of LBs to the total above.