amazon-web-servicesamazon-iamelastic-stackmetricbeat

How can I let metricbeat use iam policy to access other AWS account?


I am using metricbeat to monitor metrics from a few AWS accounts. I have read through the doc: https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-aws.html

it says to configure the credential as environment variables or in aws credential file. But I'd like to use cross account IAM policy to access different AWS account. That means metricbeat needs to assume a role when it tries to query metrics. How can I achieve this in metrcibeat? I can't find related doc in their document.


Solution

  • So you can specify the IAM Role like this

    Metricbeat Configuration Params

    metricbeat.modules:
    - module: aws
      period: 300s
      metricsets:
        - ec2
      role_arn: arn:aws:iam::123456789012:role/test-mb
    

    I would say there is nothing like Cross Account Policy.

    Your role has permissions based on the policies you assign to it via IAM Policies.

    When you wanna use Cross-Account IAM Roles, you still have to assign IAM Policies on the role you create in the destination account + an IAM Trust Policy as well so that you can assume the role from another account, In addition to that your source IAM Role must have permissions to assume the destination IAM Role

    IAM Role Delegation

    How to use trust policies with IAM roles

    IAM Tutorial: Delegate access across AWS accounts using IAM roles