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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New resource: aws_macie_member_account_association #5283

Merged
merged 1 commit into from
Jul 30, 2018

Conversation

ewbankkit
Copy link
Contributor

Fixes #5202.

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Jul 20, 2018
@ewbankkit
Copy link
Contributor Author

Still WIP as I investigate how to deal with the setup steps for Macie member accounts.
Current acceptance tests:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSMacieMemberAccountAssociation_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -run=TestAccAWSMacieMemberAccountAssociation_ -timeout 120m
=== RUN   TestAccAWSMacieMemberAccountAssociation_self
--- PASS: TestAccAWSMacieMemberAccountAssociation_self (16.57s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	16.580s

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Jul 29, 2018
@ewbankkit
Copy link
Contributor Author

For acceptance tests the environment variable MACIE_MEMBER_ACCOUNT_ID should be set the the AWS account ID of an account that has had the setup steps applied.

$ MACIE_MEMBER_ACCOUNT_ID=123456789012 make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSMacieMemberAccountAssociation_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -run=TestAccAWSMacieMemberAccountAssociation_ -timeout 120m
=== RUN   TestAccAWSMacieMemberAccountAssociation_basic
--- PASS: TestAccAWSMacieMemberAccountAssociation_basic (17.67s)
=== RUN   TestAccAWSMacieMemberAccountAssociation_self
--- PASS: TestAccAWSMacieMemberAccountAssociation_self (19.48s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	37.166s

@ewbankkit ewbankkit changed the title [WIP] New resource: aws_macie_member_account_association New resource: aws_macie_member_account_association Jul 29, 2018
@ewbankkit
Copy link
Contributor Author

Removed WIP.

@bflad bflad added new-resource Introduces a new resource. service/macie Issues and PRs that pertain to the macie service. labels Jul 30, 2018
@bflad bflad added this to the v1.30.0 milestone Jul 30, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- thanks @ewbankkit! Verified between two test accounts after creating the required IAM setup. 🚀

locals {
  macie_master_account_id = "..."
}

resource "aws_iam_service_linked_role" "AWSServiceRoleForAmazonMacie" {
  aws_service_name = "macie.amazonaws.com"
}

resource "aws_iam_role" "AWSMacieServiceCustomerHandshakeRole" {
  name = "AWSMacieServiceCustomerHandshakeRole"

  assume_role_policy = <<POLICY
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "macie.amazonaws.com"
      },
      "Condition": {
        "StringEquals": {
          "sts:ExternalId": "${local.macie_master_account_id}"
        }
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
POLICY
}

resource "aws_iam_role_policy_attachment" "AWSMacieServiceCustomerHandshakeRole-AmazonMacieHandshakeRole" {
  policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonMacieHandshakeRole"
  role       = "${aws_iam_role.AWSMacieServiceCustomerHandshakeRole.name}"
}
make testacc TEST=./aws TESTARGS='-run=TestAccAWSMacieMemberAccountAssociation'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSMacieMemberAccountAssociation -timeout 120m
=== RUN   TestAccAWSMacieMemberAccountAssociation_basic
--- PASS: TestAccAWSMacieMemberAccountAssociation_basic (13.78s)
=== RUN   TestAccAWSMacieMemberAccountAssociation_self
--- PASS: TestAccAWSMacieMemberAccountAssociation_self (13.65s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	28.038s


In addition to all arguments above, the following attributes are exported:

* `id` - The ID of the association.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: We might want to clarify that this is the member account ID

@bflad bflad merged commit 4d8ca0d into hashicorp:master Jul 30, 2018
bflad added a commit that referenced this pull request Jul 30, 2018
@ewbankkit ewbankkit deleted the issue-5202 branch July 31, 2018 11:50
@bflad
Copy link
Contributor

bflad commented Aug 2, 2018

This has been released in version 1.30.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 4, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-resource Introduces a new resource. service/macie Issues and PRs that pertain to the macie service. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New resource: Amazon Macie account association
2 participants