Skip to content

Terraform module for integrating AWS accounts with the nOps Compute Copilot ASG product

Notifications You must be signed in to change notification settings

nops-io/terraform-aws-nops-compute-copilot-asg-onboarding

Repository files navigation

nOps AWS Compute Copilot ASG Onboarding Terraform Module

Description

This module creates the necessary infrastructure on your AWS accounts to integrate the nOps Compute Copilot ASG product with your environments.

Features

  • Creation of a nASG Lambda and related resources such as event bus to react to EC2 events
  • Creation of IAM roles with minimum privileges for the Lambdas to run
  • Self test and checks when deploying
  • Auto update of main Lambda when a new version is deployed
  • Integration with nOps APIs for metadata fetching

Prerequisites

  • Terraform v1.0+
  • AWS CLI configured with appropriate permissions
  • nOps API key

Usage

Compute Copilot ASG Onboarding

In order to onboard your AWS account with the nOps ASG product, use the following snippet while being logged in onto the target account. We only support us-east-1and us-west-2 as deployment regions for the main module, deployment will fail if other regions are attempted.

terraform {
  required_providers {
    nops = {
      source = "nops-io/nops"
    }
    aws = {
      source  = "hashicorp/aws"
    }
  }
}

provider "nops" {
  nops_api_key = "XXXX.XXXXXX"
}

module "cc_asg" {
  source = "nops-io/nops-compute-copilot-asg-onboarding/aws"
  token = "XXXX.XXXXXXXXX"
}

After the previous deployment finishes, onboard additional regions by deploying the forwarder submodule into the desired regions.

terraform {
  required_providers {
    nops = {
      source = "nops-io/nops"
    }
    aws = {
      source  = "hashicorp/aws"
    }
  }
}

provider "nops" {
  nops_api_key = "XXXX.XXXXXX"
}

module "cc_asg_forwarder" {
  source = "nops-io/nops-compute-copilot-asg-onboarding/aws//modules/forwarder"
  # Region where the main module was deployed, either us-east-1 or us-west-2.
  nasg_central_region = "us-east-1"
}

Requirements

Name Version
terraform >= 1.5
archive >= 2.7.0
aws >= 4.0
nops ~> 0.0.7

Providers

Name Version
archive >= 2.7.0
aws >= 4.0
nops ~> 0.0.7

Modules

No modules.

Resources

Name Type
aws_cloudwatch_event_bus.nops_asg_ec2_instance_state_change resource
aws_cloudwatch_event_rule.asg_ec2_spot_termination_warning resource
aws_cloudwatch_event_rule.auto_update resource
aws_cloudwatch_event_rule.ec2_instance_launch_unsuccessful resource
aws_cloudwatch_event_rule.scheduled_check resource
aws_cloudwatch_event_target.asg_ec2_spot_termination_target resource
aws_cloudwatch_event_target.auto_update_target resource
aws_cloudwatch_event_target.ec2_instance_launch_unsuccessful_target resource
aws_cloudwatch_event_target.scheduled_check_target resource
aws_iam_policy.nasg_auto_updater_policy resource
aws_iam_policy.nasg_function_policy resource
aws_iam_policy.nasg_regions_checker_policy resource
aws_iam_policy.nasg_role_checker_policy resource
aws_iam_policy.nops_cross_account_policy resource
aws_iam_role.nasg_auto_updater_role resource
aws_iam_role.nasg_function_role resource
aws_iam_role.nasg_regions_checker_role resource
aws_iam_role.nasg_role_checker_role resource
aws_iam_role.nops_cross_account_role resource
aws_iam_role_policy_attachment.aws_lambda_basic_execution resource
aws_iam_role_policy_attachment.aws_lambda_basic_execution_auto_updater resource
aws_iam_role_policy_attachment.nasg_auto_updater_policy_attachment resource
aws_iam_role_policy_attachment.nasg_function_policy_attachment resource
aws_iam_role_policy_attachment.nasg_function_role_aws_lambda_basic_execution resource
aws_iam_role_policy_attachment.nasg_regions_checker_aws_lambda_basic_execution resource
aws_iam_role_policy_attachment.nasg_regions_checker_policy_attachment resource
aws_iam_role_policy_attachment.nasg_role_checker_policy_attachment resource
aws_iam_role_policy_attachment.nops_cross_account_policy_attachment resource
aws_lambda_function.nops_auto_updater_lambda resource
aws_lambda_function.nops_nasg_lambda resource
aws_lambda_function.nops_regions_checker_lambda resource
aws_lambda_function.nops_role_checker_lambda resource
aws_lambda_function.nops_self_test_lambda resource
aws_lambda_permission.auto_update_permission resource
aws_lambda_permission.ec2_instance_launch_unsuccessful_permission resource
aws_lambda_permission.ec2_spot_termination_warning_permission resource
aws_lambda_permission.scheduled_check_permission resource
archive_file.nops_auto_updater_lambda data source
archive_file.nops_regions_checker_lambda data source
archive_file.nops_role_checker_lambda data source
archive_file.nops_self_test_lambda data source
aws_caller_identity.current data source
aws_region.current data source
nops_projects.current data source

Inputs

Name Description Type Default Required
environment nASG environment string "prd" no
exclude_regions Comma-separated list of AWS region codes to exclude from deployment (e.g., us-west-1,eu-west-3). string "" no
memory_size Lambda function total memory in MB number 2048 no
timeout Lambda function timeout in seconds number 900 no
token Nops Client Token string n/a yes

Outputs

No outputs.

About

Terraform module for integrating AWS accounts with the nOps Compute Copilot ASG product

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •