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: Amazon Macie account association #5202

Closed
ewbankkit opened this issue Jul 16, 2018 · 5 comments · Fixed by #5283
Closed

New resource: Amazon Macie account association #5202

ewbankkit opened this issue Jul 16, 2018 · 5 comments · Fixed by #5283
Labels
new-resource Introduces a new resource. service/macie Issues and PRs that pertain to the macie service.
Milestone

Comments

@ewbankkit
Copy link
Contributor

Add support for associating a specified AWS account with Amazon Macie as a member account.
Follows on from #4992.
Requires #5201.

@bflad bflad added new-resource Introduces a new resource. service/macie Issues and PRs that pertain to the macie service. labels Jul 16, 2018
@ewbankkit
Copy link
Contributor Author

Fully automated acceptance tests will be difficult as there are steps that must be taken in the context of the member account to allow Macie to associate.

@bflad
Copy link
Contributor

bflad commented Jul 21, 2018

Looks like the CloudFormation template is really straightforward:

Resources:
  AWSMacieServiceCustomerHandshakeRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: AWSMacieServiceCustomerHandshakeRole
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Effect: Allow
          Principal:
            Service:
            - "macie.amazonaws.com"
          Action:
          - sts:AssumeRole
          Condition:
            StringEquals:
              "sts:ExternalId": 
              - Ref : MasterAccount
      ManagedPolicyArns:
      - arn:aws:iam::aws:policy/service-role/AmazonMacieHandshakeRole

So essentially the below (adding the service linked role for good measure):

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": "123456789012"
        }
      },
      "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}"
}

@bflad bflad added this to the v1.30.0 milestone Jul 30, 2018
@bflad
Copy link
Contributor

bflad commented Jul 30, 2018

The new aws_macie_member_account_association resource has been merged into master and will release with version 1.30.0 of the AWS provider.

@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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants