Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Add support for License Manager - Host Resource Group #25525

Open
sc250024 opened this issue Jun 22, 2022 · 2 comments
Open

[feature] Add support for License Manager - Host Resource Group #25525

sc250024 opened this issue Jun 22, 2022 · 2 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. new-resource Introduces a new resource. service/licensemanager Issues and PRs that pertain to the licensemanager service. upstream Addresses functionality related to the cloud provider.

Comments

@sc250024
Copy link

sc250024 commented Jun 22, 2022

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

As best I can tell, while there is currently support for Resource Groups (via the aws_resourcegroups_group resource), there is no support for the (annoyingly very similarly named) host resource group which is located within the AWS License Manager scope.

This is a screenshot of that resource:

license-manager-host-resource-group

I discovered the lack of this resource while trying to configure an autoscaling group comprised of metal type instances, and realized that there is a fairly lengthy process to go through on the licensing interface in order to configure this. I mistakenly thought that passing in the ARN of a aws_resourcegroups_group into the aws_launch_template was what was needed, but this is not the case.

The initial desire for this ticket was to do something like the following article: https://devdosvid.blog/2021/10/24/auto-scaling-group-for-your-macos-ec2-instances-fleet/. I noticed that this needed resource did not yet exist, so I figured I'd create an issue to create it.

Following the current resource naming conventions, this new resource would be aws_licensemanager_host_resource_group.

New or Affected Resource(s)

  • aws_licensemanager_host_resource_group

Potential Terraform Configuration

Based on the current way to configure this resource via the console...

create-host-resource-group

...the Terraform resource could probably be configured like so:

resource "aws_licensemanager_host_resource_group" "example" {
  description = "Test host resource group used for dedicated metal hosts."
  name        = "test-host-resource-group"
  tags        = { "some-key" : "some-value" }

  license_configurations = [
    aws_licensemanager_license_configuration.license1.arn,
    aws_licensemanager_license_configuration.license2.arn,
  ]

  dedicated_host_management_settings {
    allocate_hosts_automatically = true
    recover_hosts_automatically  = false
    release_hosts_automatically  = true

    instance_familes = ["m5", "m5d"]
  }
}

resource "aws_launch_template" "foo" {
  name = "foo"

  ...

  placement {
    host_resource_group_arn = aws_licensemanager_host_resource_group.example.arn
    tenancy                 = "host"
  }
}
@sc250024 sc250024 added the enhancement Requests to existing resources that expand the functionality or scope. label Jun 22, 2022
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/licensemanager Issues and PRs that pertain to the licensemanager service. labels Jun 22, 2022
@sc250024
Copy link
Author

sc250024 commented Jun 23, 2022

To anyone who reads a bit further, I checked into this, and from what I can tell, I think that the AWS API doesn't allow you to create this resource (host resource groups) directly. What's even more confusing is that AWS treats host resource groups and regular resource groups as sort of the same.

Here's an image showing this:

resource-group-discrepancy

Basically, host resource groups are treated as regular resource groups, but not the other way around.

This means that there are two places inside of the console to create resources that are almost the same. They both use the same ARN format. But if you try to pass in a regular resource group (on the right) to a launch template, it will fail.

This seems like an error in the way AWS is handling this type of resource.

@justinretzolk justinretzolk added upstream Addresses functionality related to the cloud provider. new-resource Introduces a new resource. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 20, 2022
@Kitsune-Fox
Copy link

Kitsune-Fox commented Mar 7, 2023

Hi @sc250024,

I know this is like a year too late but I was looking at doing the same thing and the AWS provider does actually allow for this.
It's created just like a RG but instead of using a resource group query, you use a service configuration.

So for instance, to set up the DRG for AWS Licence Manager, you use the configuration parameters you can find here:
https://docs.aws.amazon.com/ARG/latest/userguide/about-slg.html#about-slg-types-resourcegroups-ec2-hostmanagement

There's a AWS blog that links to a repo with examples.
https://aws.amazon.com/blogs/compute/implementing-autoscaling-for-ec2-mac-instances
https://github.com/aws-samples/amazon-autoscaling-mac1metal-ec2-with-terraform

The TF would look like this:

resource "aws_licensemanager_license_configuration"  "license_config"{  
  name                     = "MyRequiredLicense"
  description              = "Pass through configuration for Host Resource Group"
  license_count            = 32
  license_count_hard_limit = false
  license_counting_type    = "Core"
}

resource "aws_resourcegroups_group" "aws_resourcegroups_licence_group" {
  name = "LicenceManagerResourceGroup"
  configuration {
    type = "AWS::EC2::HostManagement"
    parameters {
      name   = "allowed-host-based-license-configurations"
      values = [aws_licensemanager_license_configuration.license_config.arn]
    }
    parameters {
      name   = "auto-allocate-host"
      values = [true]
    }
    parameters {
      name   = "auto-release-host"
      values = [true]
    }
    parameters {
      name   = "auto-host-recovery"
      values = [true]
    }
    parameters {
      name   = "allowed-host-families"
      values = ["mac2"]
    }
  }
  configuration {
    type = "AWS::ResourceGroups::Generic"
    parameters {
      name   = "allowed-resource-types"
      values = ["AWS::EC2::Host"]
    }
    parameters {
      name   = "deletion-protection"
      values = ["UNLESS_EMPTY"]
    }
  }
}

Hope this helps someone.

Edit:
It looks like you don't need to use the license config, so instead of this:

    parameters {
      name   = "allowed-host-based-license-configurations"
      values = [aws_licensemanager_license_configuration.license_config.arn]
    }

you can instead just use:

    parameters {
      name   = "any-host-based-license-configuration"
      values = [true]
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Requests to existing resources that expand the functionality or scope. new-resource Introduces a new resource. service/licensemanager Issues and PRs that pertain to the licensemanager service. upstream Addresses functionality related to the cloud provider.
Projects
None yet
Development

No branches or pull requests

3 participants