Skip to main content
AWS Data Collection Using a CloudFormation Template

Overview

Kubex’s CloudFormation template creates a comprised of the AWS resources required by Kubex to collect the Resource Utilization Metrics (via CloudWatch) that are then used for cloud optimization analysis. If your accounts are setup using an AWS organization/management account structure, in which many accounts are linked to one management account, you can use the CloudFormation template to create, update and delete StackSets across multiple accounts and also create the cloud connection within Kubex for each of the linked accounts. If you are not using an organizational account structure you can provide a list of accounts to be updated when you are configuring the stack.
This template creates the IAM role and access policy and assigns the policy to the role using native CloudFormation capabilities. The template then uses a Lambda function to make an API call to Kubex to create the cloud connections required to collect resource utilization data. If you need to update the IAM role or policy after they have been created, see Editing the StackSet . This may be necessary if the IAM access policy needs additional permissions.

Supported Regions

You can run the Kubex CloudFormation template in any of the following regions;
  • ap-northeast-1
  • ap-northeast-2
  • ap-south-1
  • ap-southeast-1
  • ap-southeast-2
  • eu-central-1
  • eu-north-1
  • eu-west-1
  • eu-west-2
  • eu-west-3
  • ca-central-1
  • us-east-1
  • us-east-2
  • us-west-1
  • us-west-2
  • sa-east-1
The Kubex CloudFormation template must be run in a single region, even if the target accounts span multiple regions. The template creates an IAM role and permission policy which are both global and are not region-specific. Please contact Support@Kubex.ai if you need to run the template in regions, not listed above.

Additional Considerations Regarding Regions

When you create the StackSet, you need to specify a region from where the stack is deployed to each account and from where the Lambda function runs. Ensure you specify a single region as the IAM role and permission policy are globally accessible and as such will work from any region. If you try to re-run the template in a different region it will fail as the IAM role and the permission policy already exist. The Lambda function is region-specific and creates the cloud connections within Kubex during deployment. CloudFormation can also invoke it when its custom resources are updated or deleted. The StackSet and the CloudWatch logs that result from running the template are also region-specific and are defined within a specific region. You need to log into the specified region to manage your Stack and view its related log files. These log files will be required by the Kubex support team, if troubleshooting any data collection issues.

Using the CloudFormation Template

If your AWS accounts are setup using an organizational structure, in which many accounts are linked to one management account, you can use the CloudFormation template to create, update and delete stacks across multiple accounts and also create the cloud connection within Kubex for each of the linked accounts. If you are using this organizational structure, your AWS sign-in must have sufficient permissions to deploy the StackSet and create the required IAM roles and policies in the linked accounts. If you are not using an organizational account, you can provide a list of accounts in which the CloudFormation template will run and create the required prerequisites for data collection. In addition to creating connections from your linked accounts, you also need to create a connection for your payer accounts. The payer account connection provides the name of each linked accounts.

Prerequisites

Obtain the following required inputs for the template before starting:
  • External ID for IAM Role—This value is similar to a password and should be unique and difficult to guess. Kubex recommends using a password generator to create a random, alphanumeric string (e.g. ae73mcf4ldjpet96) for the external ID.
  • Both the URL and user credentials for your Kubex instance—Contact your Kubex Account Manager for details if you do not have this information.
  • AWS permissions—If you are using an AWS Organization with multiple linked accounts, your AWS sign-in must have sufficient permissions to deploy the StackSet and create the required IAM roles and policies in those accounts.

Considerations when Working with Large Environments

In large environments, Kubex highly recommends batching your accounts into smaller groups for improved performance when using the CloudFormation templates. i.e. no more than 10 accounts at a time. You can use a resource tag, such as application or business unit to separate the CloudFormation stack so that data is collected in manageable batches.

Configuring and Running the Template

Step 1: Choose a Template

  1. Log into the AWS Management Console and navigate to CloudFormation and select StackSets. You may need to expand the options in the upper left corner of the page:
  1. At the top of the StackSets page, select a supported region. See the list of Supported Regions.
  2. Click Create StackSet to begin.
  1. In the Permissions section at the top of the page select the applicable option.
Your selection, here depends on the nature of your organizational structure and your specific requirements for managing permissions across accounts.
  • Service-managed permissions—Use this option when you want the AWS Organization to automatically manage permissions. This is useful if you have a large number of accounts under an organization and you want to simplify the management of permissions across these accounts.
  • Self-managed permissions—Use this option when you need more granular control over permissions or when you are working in an environment where accounts are not part of the same AWS organizational structure.
  1. If you selected “Self-managed permissions”, then specify an IAM role that has execute privileges in your target linked accounts.
  1. In the next section, Prerequisite - Prepare template, select Template is ready
  2. In Specify template, paste the following URL into the Amazon S3 URL field: https://kubex-cf-template.s3.us-east-2.amazonaws.com/Kubex_CloudFormation.yml
    Already using the Densify template? Continue using it. See Editing the StackSet for the latest template and update guidance.
  3. Click Next to proceed with creating the stack.

Step 2: Specify StackSet Details

  1. Enter the following StackSet details:
  • Stack name—Kubex-Data-Collection, as an example.
  • Stack description—Optionally enter a description for this StackSet
  1. Enter the following Kubex instance details:
  • Kubex Instance URL—This is your Kubex SaaS instance.
  • Kubex User ID—This is your Kubex user name.
  • Kubex Password—This is the password for the listed user name.
  1. Enter the External ID for IAM Role that you prepared in the prerequisites.
  2. The values for IAM Role Name and the Permission Policy Name fields are provided. You do not need to enter any values here.
  3. Click Next to proceed with creating the stack.

Step 3: Configure StackSet Options

  1. In the Configure StackSet options page, accept the default values and then click Next.
  • Tags—No tags need to be specified for the StackSet.
  • Inactive—Leave this value to simplify StackSet execution.

Step 4: Set Deployment Options

Set the following deployment options
  1. In the first section, Add stacks to stack set select Deploy new stacks.
  1. Under Accounts > Deployment locations , define the accounts to which you want to deploy the StackSet:
  • Deploy Stacks in accounts—Enter the 12-digit account numbers in the field.
Alternatively, you can specify a .CSV file with the account information. The .CSV files must contain the 12-digit account numbers separated by commas.
  • Deploy stacks in organizational units—Specify the organization units to use. The StackSet will be deployed to all account in the specified organizational units.
  1. In the next section, select one region from which the StackSet will be managed. This is typically the same region from which the StackSet is deployed. See the list of Supported Regions.
  2. Set the following Deployment Options:
  • Maximum Concurrent Accounts—Choose Number from the dropdown list and enter a value of 10.
Do not set this value greater than 10. Kubex highly recommends batching your accounts into smaller groups for improved performance. Setting a higher number is faster for AWS operations, but creating the cloud environments and initiating data collection within Kubex is negatively impacted if more than 10 accounts are run concurrently.
  • Failure Tolerance (Optional)—Specify the maximum number or percentage of stack operation failures allowed per region. If this threshold is exceeded, CloudFormation stops the operation.
When using Strict failure tolerance with account counts, Maximum Concurrent Accounts cannot exceed Failure Tolerance + 1. For example, a concurrency setting of 10 requires a failure tolerance of at least 9.
  • Region Concurrency—Select the desired option. As long as Maximum Concurrent Accounts is specified, parallel is preferred.
  • Concurrency Mode—Leave the default value, of “Strict failure tolerance”.
  1. Click Next to proceed with creating the stack.

Step 5: Review

  1. Scroll through each section and verify the data you have entered.
  2. At the bottom of the page, in the Capabilities section, click the checkbox to acknowledge that the StackSet will create IAM resources with custom names, as required.

Step 6: Run the Template

  1. Click Submit to begin the process. The CloudFormation dashboard displays the stack creation progress.
  2. Open the StackSet’s Operations tab to monitor deployment progress and status.
  3. After deployment succeeds, open the Stack instances tab and follow a stack ID link to view an individual stack:
    • Open Events to review that stack’s deployment events.
    • Open Resources to review the created resources.
    • Open Outputs to review the template and Lambda version information.
  4. You can also log into your Kubex instance and verify that the cloud connections are listed in the Cloud Connection wizard.
The initial audit will pick up historical data, if configured and available and each daily audit will collect the last 24-hours of data. If this is a new or trial deployment, you will be contacted, once your data has been analyzed and is ready to review. Otherwise, analysis will be run overnight and you can review the optimization results the morning after creating the cloud connections. See Viewing the Optimization Overview Report for analysis results.

Other StackSet Operations

To update an existing StackSet, choose Actions > Edit StackSet details and use the appropriate Kubex template update.Existing Densify deployments: Continue using the Densify template; switching to the Kubex template is not supported.
If your accounts are setup using an organizational structure you can use the CloudFormation template to update stacks across the multiple linked accounts and also create the cloud connection within Kubex for each of the linked accounts. After the initial StackSet deployment you can do the following:
  • Push changes to the existing stack in your accounts.
  • Add the stack to additional accounts.
  • Delete the stack from the accounts.

Editing the StackSet

In most cases you will only need to edit the set of minimum required permissions. The list of minimum required permissions changes as Kubex adds new features and functionality,
  1. Log into the AWS Management Console and navigate to CloudFormation and select StackSets.
  2. Select the StackSet you want to edit and then choose Actions > Edit StackSet details from the dropdown menu at the top of the page.
For Kubex template updates, use the latest Kubex template. See the Kubex release manifest for current versions and release history.
Existing Densify deploymentsContinue using the latest Densify template. Switching to the Kubex template is not supported.See the Densify release manifest for current versions and release history.
Refer to the AWS documentation for additional details on modifying a StackSet after it has been deployed.

Adding the StackSet to New Accounts

  1. Log into the AWS Management Console and navigate to CloudFormation and select StackSets.
  2. Select the StackSet you want to add and then choose Actions > Add new stacks to StackSet then specify the new accounts as outlined in Step 4.
When adding accounts, deploy the template currently associated with your StackSet.

Deleting a StackSet from Accounts

  1. Log into the AWS Management Console and navigate to CloudFormation and select StackSets.
  2. Select the StackSet you want to delete and then choose Actions > Delete stacks from StackSet then specify the accounts as outlined in Step 4.
  3. Navigate to Set Deployment Options and edit the list of accounts.
  1. Deleting the stacks also removes the associated cloud connections from Kubex.
Refer to the AWS documentation for additional details on deleting a StackSet after it has been deployed.