Skip to content

Terraform module for deploying a production grade Cloud Carbon Footprint instance on AWS.

License

Notifications You must be signed in to change notification settings

feraudt/terraform-aws-ccf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-aws-ccf

This Terraform module provides a production grade Cloud Carbon Footprint deployment with all the necessary infrastructure on AWS.

It also features an optional AWS Cost & Usage Report service in case none is already available.

Connection & authentication against AWS CUR is natively included. Additional connection & authentication settings for GCP and Azure can be specified through input variables.

Requirements

Name Version
terraform >= 0.13
archive ~> 2.4.0
aws ~> 3.27
local ~> 2.4.0
template ~> 2.2.0
time ~> 0.6.0

Providers

Name Version
archive ~> 2.4.0
aws ~> 3.27
aws.cur ~> 3.27
local ~> 2.4.0
template ~> 2.2.0
time ~> 0.6.0

Modules

No modules.

Resources

Name Type
aws_acm_certificate.app resource
aws_acm_certificate_validation.app resource
aws_autoscaling_group.app resource
aws_autoscaling_schedule.app resource
aws_cloudwatch_log_group.crawler resource
aws_cloudwatch_log_group.lambda resource
aws_cur_report_definition.athena_cur resource
aws_glue_catalog_database.cur resource
aws_glue_catalog_table.cur resource
aws_glue_crawler.cur resource
aws_glue_registry.cur resource
aws_glue_schema.cur resource
aws_iam_instance_profile.app resource
aws_iam_policy_attachment.additional_policies resource
aws_iam_role.ccf_api resource
aws_iam_role.crawler resource
aws_iam_role.cur resource
aws_iam_role.lambda resource
aws_iam_role_policy.athena resource
aws_iam_role_policy.ce resource
aws_iam_role_policy.crawler resource
aws_iam_role_policy.cur_assume_role resource
aws_iam_role_policy.glue resource
aws_iam_role_policy.lambda resource
aws_iam_role_policy.s3 resource
aws_lambda_function.run_crawler resource
aws_lambda_permission.allow_bucket_exec resource
aws_launch_configuration.app resource
aws_lb.app resource
aws_lb_listener.app resource
aws_lb_listener.http_redirect resource
aws_lb_target_group.app resource
aws_route53_record.app resource
aws_route53_record.validation resource
aws_s3_bucket.cur resource
aws_s3_bucket.result resource
aws_s3_bucket_notification.cur resource
aws_s3_bucket_policy.allow_cur_access resource
aws_s3_bucket_public_access_block.cur resource
aws_s3_bucket_public_access_block.result resource
aws_s3_bucket_server_side_encryption_configuration.cur resource
aws_s3_bucket_versioning.cur resource
aws_s3_bucket_versioning.result resource
aws_security_group.app resource
aws_security_group_rule.egress_all_traffic resource
aws_security_group_rule.ingress_tcp resource
time_sleep.crawler_role resource
archive_file.lambda data source
aws_acm_certificate.issued data source
aws_iam_policy.additional_policies data source
aws_iam_policy_document.allow_cur_access data source
aws_iam_policy_document.athena data source
aws_iam_policy_document.ce data source
aws_iam_policy_document.crawler data source
aws_iam_policy_document.crawler_assume_role data source
aws_iam_policy_document.crawler_trigger data source
aws_iam_policy_document.cur data source
aws_iam_policy_document.cur_assume_role data source
aws_iam_policy_document.ec2_assume_role data source
aws_iam_policy_document.glue data source
aws_iam_policy_document.lambda_assume_role data source
aws_iam_policy_document.s3 data source
aws_kms_key.s3 data source
aws_partition.current data source
aws_route53_zone.selected data source
local_file.nginx_conf data source
template_file.docker_compose data source
template_file.user_data data source

Inputs

Name Description Type Default Required
additional_policies_arns The ARNs of existing IAM policies to attach to the instance profile role in addition to the ones created by this module list(string) [] no
additional_tags The tags to add to the resources map(any)
{
"project": "green-it",
"terraform_managed": true
}
no
ami The image id to build the instance from (set empty for CUR ONLY deployments) string n/a yes
app The name of this app string "ccf" no
asg_additional_scaling_configs Additional ASG scaling configs than can be referenced in asg_scaling_actions (a 'default' config with the values from asg_size and a 'zero' config already exist)
map(object({
min_size = number
max_size = number
desired_size = number
}))
{} no
asg_enable_scaling_actions Wether to activate ASG scaling actions defined in asg_scaling_actions or not bool false no
asg_health_check The health check settings of the instances autoscalling group
object({
grace_period = number
type = string
})
{
"grace_period": 300,
"type": "EC2"
}
no
asg_scaling_actions The cron expressions and scaling configs name to configure recurring ASG scaling actions ('default' config with values from asg_size and 'zero' already exist, additional configs can be defined in asg_additional_scaling_configs)
list(object({
name = string
cron = string
scaling_config = string
}))
[] no
asg_scaling_actions_timezone The timezone used for scaling actions string "Europe/Paris" no
asg_size The capacity settings of the instances autoscalling group
object({
min = number
max = number
desired = number
})
{
"desired": 1,
"max": 2,
"min": 1
}
no
aws_region The region to deploy into (set empty for CUR ONLY deployments) string n/a yes
ccf_api_image The name and version tag of the CCF api image to deploy
object({
name = string
version = string
})
{
"name": "docker.io/cloudcarbonfootprint/api",
"version": "latest"
}
no
ccf_app_account The name and id of the AWS account where the CCF app will be deployed (for CUR ONLY deployments)
object({
name = string
id = string
})
{
"id": "",
"name": ""
}
no
ccf_aws_cloud_usage_target_accounts The list of accounts to retrieve data from with Cloud Usage API approach if AWS_USE_BILLING_DATA=false (format: "[{"id":"<account1_id>","name":"<account1_name>"},{...}]") string "" no
ccf_aws_compute_optimizer_bucket The name of the AWS bucket in which Compute Optimizer recommendations exist (only for ComputeOptimizer or All AWS_RECOMMENDATIONS_SERVICE string "" no
ccf_aws_include_estimates Use this to include AWS estimations bool true no
ccf_aws_recommendations_service The AWS service used to get recommendations from (RightSizing/ComputeOptimizer/All) string "Rightsizing" no
ccf_aws_use_billing_data Use this to configure the application to query Cost and Usage Reports via AWS Athena bool true no
ccf_azure_auth_mode The authentication mode for Azure string "default" no
ccf_azure_client_id The Azure Service Principal ID with permission to read the Consumption API from your Subscriptions string "" no
ccf_azure_client_secret The Azure Service Principal Secret with permission to read the Consumption API from your Subscriptions string "" no
ccf_azure_cloud_usage_target_subscriptions List of subscriptions by IDs to include in estimations (format: ["sub_1","..."]) string "" no
ccf_azure_consumption_chunk_days Use this to specify the chunk size to avoid rate limiting number 5 no
ccf_azure_include_estimates Use this to include Azure estimations bool true no
ccf_azure_query_data Whether the app should query for Azure data or not bool false no
ccf_azure_resource_tag_names Azure resource tag names to include if present, include resourceGroup as a tag name if needed (format: ["tag_1","..."]) string "[\"resourceGroup\", \"project\", \"customer\"]" no
ccf_azure_subscription_chunks Use this to specify a group size of subscipritions for asynchronous requests to avoid rate limiting number 10 no
ccf_azure_tenant_id Your Azure tenant id string "" no
ccf_azure_use_billing_data Use this to configure the application to query Azure Consumption API bool true no
ccf_client_image The name and version tag of the CCF client image to deploy
object({
name = string
version = string
})
{
"name": "docker.io/cloudcarbonfootprint/client",
"version": "latest"
}
no
ccf_cors_allow_origin A list of one or more origins to allow for CORS requests, comma separated string "" no
ccf_cors_enable Enables default CORS headers on all API requests bool true no
ccf_electricity_maps_token Enable the use of Electricity Maps API for realtime carbon intensity emissions factors instead of the default values string "" no
ccf_gcp_application_credentials_path The absolute path to your service account private key file string "" no
ccf_gcp_big_query_table The name of your BigQuery table configured to consume Billing Export data string "" no
ccf_gcp_billing_project The GCP Project id and name that your service account exists in
object({
id = string
name = string
})
{
"id": "",
"name": ""
}
no
ccf_gcp_cloud_usage_target_projects This is array of objects with keys id and name that match the target GCP Projects with Cloud Usage API approach if GCP_USE_BILLING_DATA=false (format: "[{"id":"<account1_id>","name":"<account1_name>"},{...}]") string "" no
ccf_gcp_include_estimates Use this to include GCP estimations bool true no
ccf_gcp_query_data Whether the app should query for GCP data or not bool false no
ccf_gcp_use_billing_data Use this to configure the application to query Billing Export Data via Google BigQuery bool true no
ccf_gcp_use_carbon_free_energy_percentage Setting this to true will change the emissions factors used by the application to take into account Google's Carbon Free Energy percentage in each region bool true no
ccf_gcp_vcpus_per_composer_env Use this to configure the average number of vCPUs the application should use to estimate energy consumption of Cloud Composer Environments number 14 no
ccf_gcp_vcpus_per_gke_cluster Use this to configure the average number of vCPUs the application should use to estimate energy consumption of Kubernetes Engine clusters number 3 no
ccf_gcs_cache_bucket_name Is the name of you Google Cloud Storage bucket where the cache file will be stored string "" no
ccf_gcs_cache_mode Set with GCS to use this option or leave it empty to use the default string "" no
ccf_on_prem_avg_watts_desktop For on-premise servers, provides an average value for average watts number 300 no
ccf_on_prem_avg_watts_laptop For on-premise servers, provides an average value for average watts number 300 no
ccf_on_prem_avg_watts_server For on-premise servers, provides an average value for average watts number 300 no
ccf_on_prem_cpu_util_desktop For on-premise servers, provides an average value for cpu utilization number 40 no
ccf_on_prem_cpu_util_laptop For on-premise servers, provides an average value for cpu utilization number 40 no
ccf_on_prem_cpu_util_server For on-premise servers, provides an average value for cpu utilization number 40 no
ccf_react_base_url The base URL used to make API requests string "" no
ccf_react_date_range_type The legacy type of time period to be used (day/week/month/quarter/year) string "month" no
ccf_react_date_range_value The legacy quantity of REACT_APP_DATE_RANGE_TYPE to be used number 1 no
ccf_react_disable_cache Set to true to disable caching bool false no
ccf_react_disable_forecast_validation Set to true to disable recommendations forecast validation bool false no
ccf_react_end_date Set the date range to query data based on custom start/end timestamps (format: mm-dd-yyyy) string "" no
ccf_react_group_by Value to set how the cloud provider queries should return data (day/week/month/quarter/year) string "day" no
ccf_react_min_date_age The legacy amount of days to subtract from current date as end date number 30 no
ccf_react_page_limit The pagination limit for fetched estimates per request number 50000 no
ccf_react_previous_year_of_usage Use this to ensure the application requests usage data from the entire previous calendar year to today bool true no
ccf_react_start_date The date range to query data based on custom start/end timestamps (format: mm-dd-yyyy) string "" no
certificate_domain_name The domain name of the certificate for HTTPS if it has already been issued (with wildcards if needed) string "" no
cur_billing_account The name and id of the AWS target account where the billing report is
object({
name = string
id = string
})
{
"id": "",
"name": ""
}
no
cur_billing_bucket_id The name of the S3 cur billing data bucket on the target account for APP ONLY deployments string "" no
cur_frequency The time unit of the CUR report (DAILY, HOURLY, MONTHLY) string "DAILY" no
cur_glue_db_name The name of your target AWS Athena Database with CUR data for APP ONLY deployments string "" no
cur_glue_table_name The name of your target AWS Athena Table with CUR data for APP ONLY deployments string "" no
cur_lambda_func_path The path to the lambda function file, this module provides one under the templates directory string "src/index.js" no
cur_query_result_bucket_id The target AWS S3 Bucket that you want your Athena query results to reside in for APP ONLY deployments string "" no
cur_s3_kms_key The ID of the KMS key used for the S3 CUR bucket encryption string "alias/aws/s3" no
cur_target_iam_role_name The name of the IAM role to assume in the target acccount for APP ONLY deployments string "" no
default_security_group_ids The list of security group IDs to add to the instances in the ASG (set empty for CUR ONLY deployments) list(string) n/a yes
deploy_app Whether to deploy the CCF app and create the required resources or not bool true no
deploy_cur Whether to deploy the CUR resources & services or not bool false no
docker_compose_path The path to the docker-compose.yml file, this module provides one under the templates directory string "docker/docker-compose.yml.tftpl" no
environment The deployment environent name string n/a yes
instance_type The size of the instances string "t3.medium" no
key_name The name of the key to SSH into the instances string "" no
nginx_conf_path The path to the nginx.conf file, this module provides one under the templates directory string "nginx/nginx.conf.tftpl" no
resource_aws_tags The keys of the AWS tags to include in the report table to allow resources grouping and filtering list(string)
[
"createdBy"
]
no
resource_user_tags The keys of the user tags to include in the report table to allow resources grouping and filtering list(string)
[
"app",
"environment",
"project"
]
no
route53_zone_name The domain name of the hosted zone to create the app host domain into (set empty for CUR ONLY deployments) string n/a yes
subnet_ids The list of subnet IDs to add to the instances in the ASG (set empty for CUR ONLY deployments) list(string) n/a yes
user_data_additional_bash_commands Any bash commands to execute in the user_data script (before sarting containers), typically your container registry login commands string "" no
user_data_path The path to the user_data script file, this module provides one under the templates directory string "templates/user_data.sh.tftpl" no
vpc_id The ID of the target VPC to deploy the app resources into (set empty for CUR ONLY deployments) string n/a yes

Outputs

Name Description
app_route53_record_name The domain name attached to the CCF app
cur_billing_bucket_id The id of the S3 bucket containing the CUR in the target account
cur_glue_db_name The name of the Glue db containing the CUR table in the target account
cur_glue_table_name The name of the Glue table containing the CUR in the target account
cur_query_result_bucket_id The id of the S3 bucket containing the Athena query results in the target account
cur_target_iam_role_name The name of the IAM role in the target account to be assumed by the app instance

About

Terraform module for deploying a production grade Cloud Carbon Footprint instance on AWS.

Resources

License

Stars

Watchers

Forks

Languages