Giter Club home page Giter Club logo

auto-tag's Introduction

Auto Tag

Build Status Software License GitHub last commit Powered By: GorillaStack

This is an open-source tagging solution for AWS. Deploy AutoTag to Lambda using CloudTrail consumed through CloudWatch Events and have each of your resources tagged with the ARN of who created it. Optionally, resources can be tagged with when it was created and which AWS service invoked the request if one is provided. It was written by GorillaStack.

Read a blog post about the project.

Also see retro-tag for a solution to retrospectively tagging your resources using CloudTrail data.

About

Automatically tagging resources can greatly improve the ease of cost allocation and governance.

CloudWatch events delivers a near real-time stream of CloudTrail events as soon as a supported resource type is created. CloudWatch event rules triggers our AutoTag code to tag the resource. In this configuration the Lambda function is executed once each time it is triggered by the CloudWatch Event Rule (one event at a time). The CloudWatch Event Rule includes a pattern filter so it is only triggered by the supported events, meaning fewer Lambda invocations and lower operational costs.

Installation

The infrastructure consists of:

  • S3 Bucket
  • Main CloudFormation Stack (1 AWS region)
    • Lambda Function
    • IAM Role
  • Collector CloudFormation Stack (All active AWS regions)
    • CloudWatch Events Rule
    • SNS Topic

Custom Tags

Add pre-defined static tagging or custom tagging from the CloudTrail event. Using a JSON document, define one or more tags with either a hard-coded value or a value extracted from the CloudTrail event using variable substitution. Hard-coded tags will be applied to all supported AWS resources. When using variable substitution more than one variable can be provided in a single tag value, and if all of the substitutions in the field fail to be resolved the tag will not be written. That will allow for custom tags to be created using certain CloudTrail event fields that may not exist in all CloudTrail event types. Check out the CloudTrail Log Event Reference for the most common fields. Also, each AWS resource will have unique fields in the requestParameters and responseElements fields that can be used. Examples of specific AWS resource CloudTrail events can be found at CloudTrail Log File Examples or by searching in the CloudTrail event history.

Example:

{
  "AutoTag_ManagedBy": "Site Reliability Engineering",
  "AutoTag_UserIdentityType": "$event.userIdentity.type",
  "AutoTag_UserName": "$event.userIdentity.userName",
  "AutoTag_ClientInfo": "SourceIP: $event.sourceIPAddress - UserAgent: $event.userAgent",
  "AutoTag_Ec2_ImageId": "$event.responseElements.instancesSet.items.0.imageId"
}

Prerequisites

You will need at least 1 AWS Account, and CloudTrail should be enabled.

Deployment Methods

We have documented two different ways to deploy the infrastructure to an AWS account. Since there are CloudFormation stacks that need to be deployed in multiple regions we've provided a script that uses the AWS CLI to deploy everything for you. The other deployment method uses CloudFormation StackSets to deploy across multiple regions.

Script Deployment Method: Deploy through our script

This deploy script deploy_autotag.sh will create, delete, or update all of the AutoTag infrastructure for a single AWS account.

The script will attempt to auto-install its own dependencies: aws-cli, jq, npm, git, zip

The create command will start by creating a dedicated AutoTag S3 Bucket for storing code deployment packages in your AWS account. Then it will download or build the code package, and create both the main CloudFormation stack and the collector CloudFormation stacks. When executing the delete command all resources will be removed except the S3 bucket. Use the update-release command to update existing CloudFormation stacks to a specific release, update-master to update to the master branch (build required), or update-local to update to the local cloned git repo (build required).

Credentials

The deploy script can use all of the credential providers that the AWS CLI allows, see Configure AWS CLI and take a look at the deployment examples. A separate set of CLI credentials can be provided by the argument --s3-profile for utilizing a single S3 bucket when deploying infrastructure across multiple AWS accounts. The script will also secure the S3 bucket by blocking all public access configuration, and add the required S3 bucket-policy statement to allow the cross-account GetObject access if necessary.

IAM Policy Permissions

The script needs at minimum the IAM permissions described in this policy: deploy_iam_policy.json

Before using this IAM policy replace the 2 occurrences of my-autotag-bucket with the name of your actual AutoTag S3 bucket.

Commands and Options

Usage: deploy_autotag.sh [options] <command>

Commands:
    create                    Create the AutoTag infrastructure
    delete                    Delete the AutoTag infrastructure
    update-release            Update the AutoTag infrastructure with a specific release version
    update-master             Update the AutoTag infrastructure with the latest from the master branch
    update-local              Update the AutoTag infrastructure with the local source code

Options:
    -h   --help                  Show this screen
    -r   --region                The primary AWS region where the main CloudFormation stack will be deployed
    -p   --profile               The main AWS credential profile
    -s3bu --s3-bucket            The S3 bucket where the code package will be uploaded
    -s3pr --s3-profile           A separate AWS credential profile to upload code packages to the S3 Bucket
    -rv   --release-version      The release version to deploy, e.g. '0.5.2' or 'latest'
    
    -lr   --log-retention-days   The number of days to retain the Lambda Function's logs (default: 90)
    -ld   --log-level-debug      Enable the debug logging for the Lambda Function
    -dct  --disable-create-time  Disable the 'CreateTime' tagging for all AWS resources
    -dib  --disable-invoked-by   Disable the 'InvokedBy' tagging for all AWS resources
    -ct   --custom-tags          Define custom tags in a JSON document

Preparation

Follow these steps to prepare to run the create command.

  1. Select a primary AWS --region for the S3 bucket and the Main CloudFormation stack
  2. Pick a dedicated AutoTag --s3-bucket name, e.g. 'acme-autotag'
  3. Configure AWS credentials for the AWS CLI, see Configure AWS CLI

Deployment Examples

Download the latest version of deploy_autotag.sh, or find it in the root of the repository.

curl -LO https://raw.githubusercontent.com/GorillaStack/auto-tag/master/deploy_autotag.sh
chmod +x deploy_autotag.sh

Create the infrastructure with the latest release using either the default, $AWS_PROFILE, or instance AWS credentials profile.

./deploy_autotag.sh --region us-west-2 --s3-bucket my-autotag-bucket --release-version latest create

Create the infrastructure with the latest release using a named AWS credentials profile.

./deploy_autotag.sh -r us-west-2 -s3bu my-autotag-bucket --release-version latest --profile dev-acct create

Create the infrastructure using $AWS_ACCESS_KEY_ID and $AWS_SECRET_ACCESS_KEY.

export AWS_ACCESS_KEY_ID=XXX
export AWS_SECRET_ACCESS_KEY=YYY
./deploy_autotag.sh -r us-west-2 -s3bu my-autotag-bucket create

Create the infrastructure using a named AWS credentials profile (--profile), but with the S3 Bucket operations utilizing a separate AWS credential profile (--s3-profile). Use this feature to deploy across multiple accounts using a single S3 bucket.

./deploy_autotag.sh -r us-west-2 -s3bu my-autotag-bucket --profile dev-acct --s3-profile s3-acct create

Create the infrastructure with an additional custom tag with a static value, this tag will be applied globally across all of the supported AWS resources.

./deploy_autotag.sh -r us-west-2 -s3bu my-autotag-bucket create \
--custom-tags '{"AutoTag_ManagedBy": "Site Reliability Engineering"}'

Create the infrastructure with an additional event-based custom tag, any key in the CloudTrail event is valid to use and it will be applied globally across all of the supported AWS resources unless the field does not exist in the CloudTrail event.

./deploy_autotag.sh -r us-west-2 -s3bu my-autotag-bucket create \
--custom-tags '{"AutoTag_UserIdentityType": "$event.userIdentity.type"}'

Interpolation with text in the value is supported and more than one field from the event can be rendered in a single tag value.

./deploy_autotag.sh -r us-west-2 -s3bu my-autotag-bucket create \
--custom-tags '{"AutoTag_ClientInfo": "SourceIP: $event.sourceIPAddress - UserAgent: $event.userAgent"}'

Update the infrastructure to the bleeding edge (master).

./deploy_autotag.sh -r us-west-2 -s3bu my-autotag-bucket update-master

Update the infrastructure to the latest git release.

./deploy_autotag.sh -r us-west-2 -s3bu my-autotag-bucket --release-version latest update-release

Update the infrastructure to a specific git release - only works for releases >= 0.5.1.

./deploy_autotag.sh -r us-west-2 -s3bu my-autotag-bucket --release-version 0.5.2 update-release

Update the infrastructure to the local git folder's current state.

git clone https://github.com/GorillaStack/auto-tag.git
cd auto-tag
./deploy_autotag.sh -r us-west-2 -s3bu my-autotag-bucket update-local

Delete the infrastructure.

./deploy_autotag.sh -r us-west-2 delete

StackSet Deployment Method: Deploy using CloudFormation StackSets

CloudFormation StackSet Deployment Method

Supported Resource Types

Currently Auto-Tag, supports the following AWS resource types:

Tags Applied: C=Creator, T=Create Time, I=Invoked By

Technology Event Name Tags Applied IAM Deny Tag Support
AutoScaling Group CreateAutoScalingGroup C, T, I Yes
ASG Instances w/ENI & Vol RunInstances C, T, I Yes
Data Pipeline CreatePipeline C, T, I No
DynamoDB Table CreateTable C, T, I No
CloudWatch Alarm ? PutMetricAlarm C, T, I ?
CloudWatch Events Rule ? PutRule C, T, I ?
CloudWatch Log Group ? CreateLogGroup C, T, I ?
EBS Volume CreateVolume C, T, I Yes
EC2 AMI w/Snapshot * CreateImage C, T, I Yes
EC2 AMI w/Snapshot * CopyImage C, T, I Yes
EC2 AMI * RegisterImage C, T, I Yes
EC2 Customer Gateway ? CreateCustomerGateway C, T, I ?
EC2 DHCP Options ? CreateDhcpOptions C, T, I ?
EC2 Elastic IP AllocateAddress C, T, I Yes
EC2 ENI CreateNetworkInterface C, T, I Yes
EC2 Instance w/ENI & Volume RunInstances C, T, I Yes
EC2 / VPC Security Group CreateSecurityGroup C, T, I Yes
EC2 Snapshot * CreateSnapshot C, T, I Yes
EC2 Snapshot * CopySnapshot C, T, I Yes
EC2 Snapshot * ImportSnapshot C, T, I Yes
Elastic LB (v1 & v2) CreateLoadBalancer C, T, I No
EMR Cluster RunJobFlow C, T, I No
IAM Role CreateRole C, T, I ?
IAM User CreateUser C, T, I ?
Lambda Function ? CreateFunction20150331 C, T, I ?
Lambda Function ? CreateFunction20141111 C, T, I ?
OpsWorks Stack CreateStack C No
OpsWorks Clone Stack * CloneStack C No
OpsWorks Instances w/ENI & Vol RunInstances C, T, I Yes
RDS Instance CreateDBInstance C, T, I No
S3 Bucket CreateBucket C, T, I No
NAT Gateway CreateNatGateway C, T, I Yes
VPC CreateVpc C, T, I Yes
VPC Internet Gateway CreateInternetGateway C, T, I Yes
VPC Network ACL CreateNetworkAcl C, T, I Yes
VPC Peering Connection CreateVpcPeeringConnection C, T, I Yes
VPC Route Table CreateRouteTable C, T, I Yes
VPC Subnet CreateSubnet C, T, I Yes
VPN Connection CreateVpnConnection C, T, I Yes
VPN Gateway ? CreateVpnGateway C, T, I ?

*=not tested by the test suite

NOTE: When tag-able resources are created using CloudFormation StackSets the "Creator" tag is NEVER populated with the ARN of the user who executed the StackSet, instead it is tagged with the less useful CloudFormation StackSet Execution Role's "assumed-role" ARN.

Deny Create/Delete/Edit for AutoTags

Use the following IAM policy to deny a user or role the ability to create, delete, and edit any tag starting with 'AutoTag_'. The ec2:CreateAction condition allows users to create EC2 instances with tags starting with 'AutoTag_', this enables the 'Launch More Like This' feature, in that case the tags will be overwritten after the instance is created.

{
    "Sid": "DenyAutoTagPrefix",
    "Effect": "Deny",
    "Action": [
        "ec2:CreateTags",
        "ec2:DeleteTags",
        "autoscaling:CreateOrUpdateTags",
        "autoscaling:DeleteTags"
    ],
    "Condition": {
        "ForAnyValue:StringLike": {
            "aws:TagKeys": "AutoTag_*"
        },
        "StringNotEquals": {
            "ec2:CreateAction": [
                "RunInstances"
            ]
        }
    },
    "Resource": "*"
}

NOTE: At the time of this writing the deny tag IAM condition (aws:TagKeys) is only available for resources in EC2 and AutoScaling, see the table above for a status of each resource.

Contributing

If you have questions, feature requests or bugs to report, please do so on the issues section of our github repository.

If you are interested in contributing, please get started by forking our GitHub repository and submit pull-requests.

auto-tag's People

Contributors

balihb avatar ecout avatar em0ney avatar hiimbex avatar humblelistener avatar jheroje avatar nicholas-yong avatar rayjanoka avatar rjerrems avatar svaranasi-corporate avatar viallikavoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

auto-tag's Issues

User able to delete this tag

This tagging created by automatically and its specially use for cost management.

I noticed user able to delete this tag.

So user should not delete or edit this tag.

Tagging IAM resources

As of now, tagging is supported in IAM resources as well. This is very helpful on who has created a particular user, etc.

Use of exisiting bucket for cloudtrail

Hello,
I do already have S3 bucket with trails from multiple accounts in it. What modifications do I need to do to use the existing bucket for cloudtrail logs?

Feature to avoid overwriting of existing tags

The tags created either adds or overwrites tags to a resource. It would be great if we add tags only if they do not exist. This would help to avoid tags being overwritten by AutoTag.
We need this feature as we want to retain tags like ProductID where user assigned values can be different from the value assigned by AutoTag .

S3-hosted code is massively different from github-hosted code

The autotag-0.3.0.zip version of the code that the cloudformation template installs from S3 seems to have had a major refactor from the tagged 0.3.0 version in github.

This is not only strange but a bit concerning since anyone checking out this repo and following the setup instructions is running code that is quite different from what they would assume.

StackSet Failure

had run the prerequisite stacks for the roles in child/master accounts, ran the auto-tag stack in the master account, without issue. When running the stackset, I chose all regions, making the MainAwsRegion us-east-1 and entered all of the child account #s comma separated. The stack instances show 100 and all but two show as outdated with the operation returning "failed". On the two accounts (out of 13) that I ran this against that it created any resources, it appears to only have created the SNS topic/subscription and Cloudwatch rule. The SNS topic points to a subscriber of a Lambda AutoTag function within its own account that doesn't exist. I don't see any event in the stack where it even attempted to create this Lambda function (in child account)

CodeS3Bucket and regions

gorillastack-autotag-releases-ca-central-1 results in "Error occurred while GetObject. S3 Error Code: NoSuchBucket. S3 Error Message: The specified bucket does not exist".

This might be a case for a map.

Are we expect to install a stack in every region we want to monitor?

Function Being Invoked, Some Tags Not Working

Tagging EC2 instances works fine, however when I create an S3 bucket, that does not get tagged and I can see an invocation error occur. I'm not sure how many resource types do this, as I have not tested all, but I know at least for a fact that S3 buckets are not being tagged and I'm not sure why.

Node.js.8.10 End of Life

Will these function work if we update the Node.js.8.10 versions to to Node.js.10.x? Just starting to get EOL messages from Amazon on Node.js.8.x functions.
1/6/2020 customers won't be able to create new functions using 8.10
2/3/2020 customers won't be able to update functions using this version.
existing 8.x functions will continue to be able to process invocation events though

exception "errorMessage": "Cannot read property '0' of undefined"

{
"errorMessage": "Cannot read property '0' of undefined",
"errorType": "TypeError",
"stackTrace": [
"/var/task/aws_cloud_trail_listener.js:98:58",
"new Promise (/var/task/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:193:7)",
"AwsCloudTrailListener.retrieveLogFileDetails (/var/task/aws_cloud_trail_listener.js:96:14)",
"_callee$ (/var/task/aws_cloud_trail_listener.js:62:30)",
"tryCatch (/var/task/node_modules/babel-regenerator-runtime/runtime.js:61:40)",
"GeneratorFunctionPrototype.invoke [as _invoke] (/var/task/node_modules/babel-regenerator-runtime/runtime.js:329:22)",
"GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/var/task/node_modules/babel-regenerator-runtime/runtime.js:94:21)",
"onFulfilled (/var/task/node_modules/co/index.js:65:19)",
"/var/task/node_modules/co/index.js:54:5",
"new Promise (/var/task/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:193:7)"
]
}�

Assume Role Failing

Attempting to implement autotagging across accounts. Seems the functionality exists within the code however, execution fails with the following error.
2017-06-02T17:40:35.538Z 6cca367d-47ba-11e7-81aa-e3668cf6c658 { [AccessDenied: Not authorized to perform sts:AssumeRole]
message: 'Not authorized to perform sts:AssumeRole',
code: 'AccessDenied'

Current Deployment does currently tag instances created in the account where the lambda is running.
Any configuration assistance would be appreciated, appears this detail is missing from the Readme, or I have overlooked it.

EBS Volumes not tagged

@em0ney I was testing all resources as per your list.

Covered EC2,RDS and ELB so far all are tagged.
However EBS volumes (root and other volume) that I created with my Ec2 did not get tagged. Ec2 itself was tagged okay.
Was wondering if there is a debug option in auto tag so we get more info in Cloudwatch.

EBS volumes need to be tagged. Pl suggest.

download auto-tag for inspection

I have some security concerns with hosting a 3rd party bucket and giving it permissions to execute in my secure AWS environment. I'd like to host the autotag.zip in our own bucket so we can control when this code is updated.

I'm trying to download the existing auto-tag.zip file with no luck

Failing to launch stack

It is failing to launch stack with this error:

Error occurred while GetObject. S3 Error Code: NoSuchKey. S3 Error Message: The specified key does not exist.

AWS::Lambda::Function
AutoTagLambdaFunction

Unable to Edit React Libraries Within Lambda

Hi Guys,

Thanks so much for this solution! When I attempt to edit some of the react classes and components within your zip file and upload the refactored code to Lambda, I receive the following error. Not sure what's going on as the file still contains all of the same modules before the changes I've made.

I have specifically changed static variables and functions in the autotag_default_worker.js file. I am attempting to retrieve the User Name vice the ARN from AWS.

var AUTOTAG_TAG_NAME = 'User';
var ROLE_PREFIX = 'arn:aws:iam::';
var ROLE_SUFFIX = ':role';
var DEFAULT_STACK_NAME = 'autotag';
var MASTER_ROLE_NAME = 'AutoTagMasterRole';
var MASTER_ROLE_PATH = '/gorillastack/autotag/master/';
    key: 'getAutotagPair',
    value: function getAutotagPair() {
      return {
        Key: this.getTagName(),
        Value: this.getTagValue()
      };
    }
  }, {
    key: 'getTagName',
    value: function getTagName() {
      return AUTOTAG_TAG_NAME;
    }
  }, {
    key: 'getTagValue',
    value: function getTagValue() {
      return this.event.userIdentity.userName;
    }
  }]);

  return AutotagDefaultWorker;
}();

Here is the error message I recieve in Lambda.

{
  "errorMessage": "Cannot find module '/var/task/autotag'",
  "errorType": "Error",
  "stackTrace": [
    "Function.Module._load (module.js:276:25)",
    "Module.require (module.js:353:17)",
    "require (internal/module.js:12:17)"
  ]
}

Please let me know your thoughts.

Kind Regards

-Pat

Tagging instances launched from Service Catalog

Tagging works when I log in as tester user and launch EC2 instance via EC2 console. It creates tag in following format:

Key: AutoTag_Creator
Value: arn:aws:iam::1234567890:user/tester

I also use CFT templates to launch EC2 instance (stack) via Service Catalog. When I log in as the same tester user or any other user and launch EC2 instance (stack) via Service Catalog the instance is always getting tagged with:

Key: AutoTag_Creator
Value: arn:aws:sts::1234567890:assumed-role/LinuxUbuntuServerLaunchRole/servicecatalog

Is there a way to capture and tag authenticated user (tester) instead of assumed-role?

Simplify instructions and onboarding for users

We will do the following steps in CI/CD:

  • build code package
  • generate any CloudFormation that needs generation
  • deploy code and CF templates to S3

Simplify the README:

  • Don't require the user to do any generation of templates or uploading from their computer. Instead outline these steps in a Contribution guide or development section

Multiple issues

I had a hard time getting this to work. I set up the appropriate roles but it keeps giving same error:

{
    "errorMessage": "Cannot read property 'bucket' of undefined",
    "errorType": "TypeError",
    "stackTrace": [
        "/var/task/aws_cloud_trail_listener.js:72:38",
        "Array.map (native)",
        "/var/task/aws_cloud_trail_listener.js:71:56",
        "new Promise (/var/task/node_modules/babel/node_modules/babel-core/node_modules/core-js/modules/es6.promise.js:178:7)",
        "AwsCloudTrailListener.retrieveLogFileDetails (/var/task/aws_cloud_trail_listener.js:69:14)",
        "callee$2$0$ (/var/task/aws_cloud_trail_listener.js:40:28)",
        "tryCatch (/var/task/node_modules/babel/node_modules/babel-core/node_modules/regenerator/runtime.js:61:40)",
        "GeneratorFunctionPrototype.invoke [as _invoke] (/var/task/node_modules/babel/node_modules/babel-core/node_modules/regenerator/runtime.js:323:22)",
        "GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/var/task/node_modules/babel/node_modules/babel-core/node_modules/regenerator/runtime.js:94:21)",
        "onFulfilled (/var/task/node_modules/co/index.js:65:19)"
    ]
}

I probably bit off more than I could chew, never developing in node.js before, but I couldn't run the main.js file using provided instructions. After installing the babel-preset-es2015 package, i kept getting errors trying to find babel/polyfill.

Trust Relationship issue

I'm pretty new to Lambda and had to make a change to get auto-tag working and just wanted to make sure it wasn't something I missed.

The role that has permission to tag items, I had to update its Trust Relationship, specifying the Lambda role to be trusted. by default it was "service: lambda.amazonaws.com".

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::[account running lambda]:role/AutoTagLambdaRole"
},
"Action": "sts:AssumeRole"
}
]

Without doing this, I get the following:

User: arn:aws:sts::[my account]:assumed-role/AutoTagLambdaRole/awslambda_20160209121944195 is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::[my account]:role/AutoTagRole

It is the AutoTagLambdaRole that appears to need to be trusted, not lambda.amazonaws.com.

If this is correct, ill happily update the doco.

"errorMessage": "Cannot read property '0' of undefined"

I installed AutoTag on Friday and it seemed to be working fine (I verified it was working). Starting Sunday I started seeing errors and nothing was getting tagged. Here is the error I am seeing

{
"errorMessage": "Cannot read property '0' of undefined",
"errorType": "TypeError",
"stackTrace": [
"/var/task/aws_cloud_trail_listener.js:98:58",
"new Promise (/var/task/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:193:7)",
"AwsCloudTrailListener.retrieveLogFileDetails (/var/task/aws_cloud_trail_listener.js:96:14)",
"_callee$ (/var/task/aws_cloud_trail_listener.js:62:30)",
"tryCatch (/var/task/node_modules/babel-regenerator-runtime/runtime.js:61:40)",
"GeneratorFunctionPrototype.invoke [as _invoke] (/var/task/node_modules/babel-regenerator-runtime/runtime.js:329:22)",
"GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/var/task/node_modules/babel-regenerator-runtime/runtime.js:94:21)",
"onFulfilled (/var/task/node_modules/co/index.js:65:19)",
"/var/task/node_modules/co/index.js:54:5",
"new Promise (/var/task/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:193:7)"
]
}

The CloudTrail logs seem fine. I was able to download them and see valid content. If there are instructions to self host the code with modifications that will help a lot.

Incorrect header check

START RequestId: a01677f8-6242-11e7-b1a2-b9666a07d848 Version: $LATEST

2017-07-06T12:02:51.261Z a01677f8-6242-11e7-b1a2-b9666a07d848 { [Error: incorrect header check] errno: -3, code: 'Z_DATA_ERROR' }

2017-07-06T12:02:51.262Z a01677f8-6242-11e7-b1a2-b9666a07d848 Error: incorrect header check
at Zlib._handle.onerror (zlib.js:363:17)

2017-07-06T12:02:51.319Z a01677f8-6242-11e7-b1a2-b9666a07d848
{
"errorMessage": "incorrect header check",
"errorType": "Error",
"stackTrace": [
"Zlib._handle.onerror (zlib.js:363:17)"
]
}

END RequestId: a01677f8-6242-11e7-b1a2-b9666a07d848

error in lambda function after creating ec2 volume

Getting this error in Lambda function after creating a ec2 volume to test autotag with latest git pull (similar to this):

Syntax error in module 'autotag_event': SyntaxError
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)

Can auto-tag function stop tagging after detecting the ec2 are already tagged with specific tags?

Hi again
Currently, we have a new feature requirement to implement. Here's the scenario, when we're going to launch a new ec2 instance and the new instance has already been tagged as certain key/value using userdata or whatever. By default, the new instance will be tagged by auto-tag function as well.
Is that possible that the auto-tag function won't perform the tagging operation after detecting that the ec2 has already been tagged with specific tags ?
Appreciate it for your answer, many thanks

Error while deploying to AWS

Hello guys I'm trying to follow the installation steps in the README.md.
And I'm receiving this error from the Lambda output.

Can someone help me with that one?

image

Stack name is constrained to be AutoTag

The stack name for the event multi-region needs to be "AutoTag", as you see if it is different,
the lambda function uses the stack name for the function name.

However, event collector template, assume the lambda function name is always going to be "AutoTag"

"Endpoint": { "Fn::Sub": "arn:aws:lambda:${MainAwsRegion}:${AWS::AccountId}:function:AutoTag" },

The documentation clearly mentions the stack name can be anything, which is not true anymore.
image

instancesSet Null errors in Cloudwatch logs

I observed following errors in cloud watch logs regularly. This behavior was seen in 0.2.0 as well as in 0.3.0.
Auto Tag is adding tags to EC2 and S3 (not tested rest) but wonder what cases are missing

{ "errorMessage": "Cannot read property 'instancesSet' of null", "errorType": "TypeError", "stackTrace": [ "AutotagEC2Worker.getInstanceId (/var/task/workers/autotag_ec2_worker.js:105:41)", "_callee$ (/var/task/workers/autotag_ec2_worker.js:71:53)", "tryCatch (/var/task/node_modules/babel-regenerator-runtime/runtime.js:61:40)", "GeneratorFunctionPrototype.invoke [as _invoke] (/var/task/node_modules/babel-regenerator-runtime/runtime.js:329:22)", "GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/var/task/node_modules/babel-regenerator-runtime/runtime.js:94:21)", "onFulfilled (/var/task/node_modules/co/index.js:65:19)", "run (/var/task/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:89:22)", "/var/task/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:102:28", "flush (/var/task/node_modules/babel-polyfill/node_modules/core-js/modules/_microtask.js:18:9)", "nextTickCallbackWith0Args (node.js:415:9)" ] }

cross account access not working

I have been using Autotag for almost a month now, and it is functioning satisfactorily in all the regions. Now, I need to cover all my accounts. Can you explain how to move with that?
Just for your review, I created a role in my other account and trusted my account where autotag is working, I also added an inline policy in my Autotag execution role to assume the role in the other account. However, it is still not working. What else is needed?

The runtime parameter of nodejs4.3 is no longer supported for creating or updating AWS Lambda functions.

While deploying in ap-southeast-1, I am facing this issue:

The runtime parameter of nodejs4.3 is no longer supported for creating or updating AWS Lambda 
functions. We recommend you use the new runtime (nodejs8.10) while creating or updating functions. 
(Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; 
Request ID: XXXXXXXXXXXXXXXXX)

Any workaround on this (as I am not much familiar with node) ?

hard dependency on cloudformation?

I did considerable work on porting the cloudformation template to terraform modules and once it's deployed I see lambda error messages failing on describeStackResource. I look and see that in the node js files there appears to be a hard dependency on cloudformation now:

https://github.com/GorillaStack/auto-tag/blob/master/src/workers/autotag_default_worker.js#L36

I'd love to get this dependency removed so I can deploy this using terraform (required by my client) and do a PR to get terraform added to this project.

Anyone have an idea of how to remedy this?

Cloudwatch logs for lambda:

message: 'User: arn:aws:sts::<account>:assumed-role/AutoTagExecutionRole/AutoTag is not authorized to perform: cloudformation:DescribeStackResource on resource: arn:aws:cloudformation:us-west-2:<account>:stack/autotag/*',```




getRoleName() {
let _this = this;
return new Promise((resolve, reject) => {
try {
let cloudFormation = new AWS.CloudFormation({ region: _this.s3Region });
cloudFormation.describeStackResource({

StackName: DEFAULT_STACK_NAME,
LogicalResourceId: MASTER_ROLE_NAME
}, (err, data) => {
if (err) {
reject(err);
} else {
resolve(data.StackResourceDetail.PhysicalResourceId);
}
});
} catch (e) {
reject(e);
}
});
}

EC2 Instances not Auto-Tagged

I successfully created the "autotag" CloudFormation stack using the instructions in the readme in this repo. I can see the cloudtrail logs being generated in the S3 bucket that the stack creates, however, I'm not seeing any tags being added after I launch a new EC2 instance.

Perhaps I missed a step in the auto-tag setup or the instance launch process that tells the tags to auto add themselves? Let me know if you need any additional info from me that would be helpful in figuring out what's going on.

Thanks in advance!

incomplete Gemfile for retro_tagging

The Gemfile for the retro_tagging tool seems to be lacking the following lines:

gem 'terminal-table'
gem 'pastel'
gem 'docopt'

Without adding those, the retro_tag.rb script fails with errors of the following type:

Traceback (most recent call last):
	2: from retro_tag.rb:8:in `<main>'
	1: from /usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/usr/local/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- terminal-table (LoadError)

No package for ap-south-1 ?

Got this error:

Your access has been denied by S3, please make sure your request credentials have permission to GetObject for gorillastack-autotag-releases-ap-south-1/autotag-0.3.0.zip. S3 Error Code: AccessDenied. S3 Error Message: Access Denied (Service: AWSLambda; Status Code: 403; Error Code: AccessDeniedException;

Is there no package for ap-south-1 region ?

unable to tag resources

Hi all,
I successfully created the template but unable to tag the resource after deploy the template through cloud formation. Is there any extra steps that has to be done after deploy cloud formation template. If any plz tell me the detail.

"Unable to import module 'autotag_event'"error.

Hello,
I'm seeing the above error (from Lambda) when a new instance is created. The instance is not being tagged successfully.
I used the "CloudWatch Events Method - Multi-Region" method to install/deploy.

Full error:

Unable to import module 'autotag_event': Error
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)

Thanks for taking a look.

Basic Functionality Not Working

I tested this in my master payer account, ran the templates for the roles in there and separately in one sub-account I am testing with. Then ran the stackset, besides an STS error for most regions, it appeared to run in the 2 regions I use (the errors probably have to do with an SCP I have that limits to these 2 regions)
In any event, I logged on as a test user and created an EC2 and bucket in the test target account, and there is no activity in the Lambda function in the master payer account. Looks like the cloudwatch Auto-Tag CloudTrailLogs rule is there, but nothing is happening.

Node.js deprecated, cloudFormation templates needs to be updated

On the https://github.com/GorillaStack/auto-tag/blob/master/cloud_formation/s3object_template/autotag_s3object_main-template.json -file at row 71, the runtime is nodejs6.10. Using this template makes the stack roll back at CloudFormation, because Node 6 is deprecated. Simply changing this line to nodejs8.10 works, but as I'm fairly inexperienced at using GitHub, I prefer just writing about this issue instead of creating Pull Request.

The same issue seems to be here too: https://github.com/GorillaStack/auto-tag/blob/master/cloud_formation/event_multi_region_template/autotag_event_main-template.rb .

On the first file, the default folder and file are outdated (auto-tag-0.3.0.zip), but that's not a huge problem, as creating my own files is simple

Add additional tags

I know this is pretty basic, but I'm new to this and having some trouble. I'd like to have additional tags added to each, in addition to the owner of the resource. Is there a way to add this to the script?

"errorMessage": "Cannot read property '0' of undefined" while running lambda for retro tagging

{
"errorMessage": "Cannot read property '0' of undefined",
"errorType": "TypeError",
"stackTrace": [
"/var/task/aws_cloud_trail_log_listener.js:119:58",
"AwsCloudTrailLogListener.retrieveLogFileDetails (/var/task/aws_cloud_trail_log_listener.js:117:14)",
"_callee$ (/var/task/aws_cloud_trail_log_listener.js:66:30)",
"tryCatch (/var/task/regenerator-runtime/runtime.js:65:40)",
"GeneratorFunctionPrototype.invoke [as _invoke] (/var/task/regenerator-runtime/runtime.js:303:22)",
"GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/var/task/regenerator-runtime/runtime.js:117:21)",
"onFulfilled (/var/task/co/index.js:65:19)",
"/var/task/co/index.js:54:5",
"co (/var/task/co/index.js:50:10)",
"AwsCloudTrailLogListener.execute (/var/task/aws_cloud_trail_log_listener.js:58:31)"
]
}

Error while running the lambda for retroTagging

error after creating an IAM role

Getting this error in Lambda function after creating an IAM role to test autotag with latest git pull:

Syntax error in module 'autotag_event': SyntaxError
const handler = async (cloudtrailEvent, context) => {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)

Clarify License

Can you explicitly add an open source license to the project?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.