Git Product home page Git Product logo

Comments (12)

peaceofanotherkind avatar peaceofanotherkind commented on August 14, 2024 1

This worked perfectly! Thank you so much!

from auto-tag.

Rizbe avatar Rizbe commented on August 14, 2024

Bump

Would like to know the same

from auto-tag.

rayjanoka avatar rayjanoka commented on August 14, 2024

Hi, Can you give an example of what you would like to do?

It sounds like you want to just add an additional tag with a static key/value to every resource that is "auto-tagged"?

from auto-tag.

peaceofanotherkind avatar peaceofanotherkind commented on August 14, 2024

from auto-tag.

rayjanoka avatar rayjanoka commented on August 14, 2024

I don't think it makes sense to have AutoTag do this. AutoTag is tagging all snapshots so I'm not sure how AutoTag would know if this was one of your Backups or some other snapshot.

You can just tag the "Backup" snapshot with your tags when your function sends the snapshot create request.

See the "TagSpecification" Request Parameter of the CreateSnapshot API call.
https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateSnapshot.html

from auto-tag.

peaceofanotherkind avatar peaceofanotherkind commented on August 14, 2024

from auto-tag.

rayjanoka avatar rayjanoka commented on August 14, 2024

Ok. I agree, relying on users to remember to do something every time is never good.

One suggestion would be to create the opposite system and only tag the EC2 instances that do NOT need the backup, that is if your backup function that creates the snapshots can query for all instances and then filter out those with the tag...

from auto-tag.

rayjanoka avatar rayjanoka commented on August 14, 2024

Another suggestion would be to strictly enforce the tag's key and value for all EC2 RunInstances actions with IAM. This way aws won't allow the users to create the instance unless the tag is in the request, instead the user will get an error.

Here they have a good example of how to use the IAM Condition Key "aws:RequestTag/tag-key" for enforcing key/value under "Creating a Volume with Tags".
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ExamplePolicies_EC2.html

The IAM policy for your users might looks something like this...

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "EnforceOpsAutomatorTagOnInstances",
      "Effect": "Allow",
      "Action": "ec2:RunInstances",
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "aws:RequestTag/OpsAutomator": "Backup"
         }
       }
     }
  ]
}

from auto-tag.

peaceofanotherkind avatar peaceofanotherkind commented on August 14, 2024

Ultimately I just want every EC2 instance to be tagged with, "OpsAutomator=Backup" so that the OpsAutomator stack will automatically back it up according to our backup/retention policy. If we have a request for a specific resource to NOT be backed-up, then we can remove the tag. Since this is what we're using to auto-tag resources, it just seemed more logical to have auto-tag do this, rather than re-configuring everything else.

from auto-tag.

rayjanoka avatar rayjanoka commented on August 14, 2024

If you are using the code from master, you could fork it and add the tag to the "createTags" call in "src/workers/autotag_ec2_worker.js" like this.

tagEC2Resources(resources) {
    let _this = this;
    return new Promise((resolve, reject) => {
      try {
        _this.ec2.createTags({
          Resources: resources,
          Tags: [
            _this.getAutotagPair(),
           {Key: 'OpsAutomater', Value: 'Backup'}
          ]
        }, (err, res) => {
          if (err) {
            reject(err);
          } else {
            resolve(true);
          }
        });
      } catch (e) {
        reject(e);
      }
    });
  }

Then every instance will get the tag, but I don't think we would add this as a feature in general.

from auto-tag.

Nipazz avatar Nipazz commented on August 14, 2024

Would adding additional tags be possible in the Default_Worker? So every new resource would get the additional tag, regardless of the resource type?

from auto-tag.

rayjanoka avatar rayjanoka commented on August 14, 2024

Would adding additional tags be possible in the Default_Worker? So every new resource would get the additional tag, regardless of the resource type?

Hey Nipazz,

I think you'd want to just add it here in the default_worker...

getAutotagTags() {
    return [
      {Key: 'someNewTagKey', Value: 'someNewTagValue'},
      this.getAutotagCreatorTag(),
      ...(SETTINGS.AutoTags.CreateTime ? [this.getAutotagCreateTimeTag()] : []),
      ...(this.getInvokedByTagValue() && SETTINGS.AutoTags.InvokedBy ? [this.getAutotagInvokedByTag()] : []),
    ];
  }

from auto-tag.

Related Issues (20)

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.