Sign inSign up

dfdsdk/aws-resource-exporter

By dfdsdk

•Updated 5 months ago

Retrieves a count of resources from AWS accounts using AWS resource explorer and expose as metrics R

Image
0

10K+

dfdsdk/aws-resource-exporter repository overview

⁠AWS Resource Count Exporter

Retrieves a count of resources from AWS accounts using AWS resource explorer and expose as metrics

⁠Pre-requisites

Requires AWS resource explorer configured with a view

⁠Building the application

Run the following commands from the root directory to build the project:

mkdir bin
cd bin
go build ../cmd/aws-resource-exporter

⁠Building the Docker image

Run the following commands from the root directory to build the Docker image:

docker build -f build/package/Dockerfile -t aws-resource-exporter:test .

⁠Running the application

We suggest running the application using the Docker image. The application requires the following environment variables to be set:

  • AWS_RESOURCE_EXPORTER_ORGUNITID: The AWS organisational unit to retrieve the list of AWS accounts from.
  • AWS_RESOURCE_EXPORTER_ASSUMEROLENAME: The AWS IAM role name to assume in each AWS account.

The following environment variables are optional:

  • AWS_RESOURCE_EXPORTER_PORT: The port to run the metrics endpoint on. Defaults to `8090``
  • AWS_RESOURCE_EXPORTER_ENDPOINT: The path to expose the metrics endpoint on. Defaults to metrics
  • AWS_RESOURCE_EXPORTER_SCHEDULE: How frequently to retrieve the resource count from each AWS account in minutes. Defaults to 1440 (24 hours)
  • AWS_RESOURCE_EXPORTER_VIEWNAME: The name of the AWS Resource Explorer view to retrieve the resource count from. Defaults to all-resources
  • AWS_RESOURCE_EXPORTER_METRICPREFIX: The prefix to use for the AWS metrics. Defaults to `` (empty string):
  • AWS_RESOURCE_EXPORTER_QUERYSTRING: The additional query string to use when retrieving the resource count from AWS Resource Explorer. Defaults to `` (empty string)
  • AWS_RESOURCE_EXPORTER_INCLUDEZEROVALUES: Whether to include metrics with a value of zero. Defaults to true
  • AWS_RESOURCE_EXPORTER_INCLUDEINDIVIDUALRESOURCES: Defaults to false
  • AWS_RESOURCE_EXPORTER_INDIVIDUALRESOURCESTAGFILTER: Defaults to `` (empty string) to include all tags as metric labels

⁠Running locally

Set the required environment variables as per the above. We recommend using dotenv to set these.

Ensure that you assume a role that allows you to assume the role set in AWS_RESOURCE_EXPORTER_ASSUMEROLENAME in each AWS account. You can do this with a command such as the following:

$(aws sts assume-role \
--role-arn "arn:aws:iam::111111111111:role/role-name" \
--role-session-name aws-resource-exporter \
--query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \
--output text))

Tag summary

Content type

Image

Digest

sha256:875e908d6…

Size

40.3 MB

Last updated

5 months ago

docker pull dfdsdk/aws-resource-exporter