# tag. It then sets the output variable `instanceIDs` to the list of instances to # terminate. # Inputs: # - terminationDateTag - user configurable tag indicating when instance should be terminated # - lifetimeTag - user configurable tag indicating how long instance should live # - instances - list of instances to filter # Outputs: # - instanceIDs - list of instances to be terminated in the subsequent step import datetime import re from nebula_sdk import Interface, Dynamic as D ni = Interface() # The `MINUTES_TO_WAIT` global variable is the number of minutes to wait for # a termination_date tag to appear for the EC2 instance. Please note that the # AWS Lambdas are limited to a 5 minute maximum for their total run time. MINUTES_TO_WAIT = 4 # The Indefinite lifetime constant INDEFINITE = 'indefinite' # Tag names (user-configurable) TERMINATION_DATE_TAG = ni.get(D.terminationDateTag) LIFETIME_TAG = ni.get(D.lifetimeTag) def get_tag(ec2_instance, tag_name):
#!/usr/bin/env python import boto3 from nebula_sdk import Interface, Dynamic as D relay = Interface() session_token = None try: session_token = relay.get(D.aws.connection.sessionToken) except: pass sess = boto3.Session(aws_access_key_id=relay.get(D.aws.connection.accessKeyID), aws_secret_access_key=relay.get( D.aws.connection.secretAccessKey), aws_session_token=session_token) s3 = sess.client('s3') # region = relay.get(D.aws.region) bucketName = relay.get(D.bucketName) redirectAllRequestsToHostName = relay.get(D.redirectAllRequestsToHostName) print("Redirect all requests value {}".format(redirectAllRequestsToHostName)) if redirectAllRequestsToHostName: try: # bucket_website = s3.BucketWebsite(bucketName) websiteConfiguration = { 'RedirectAllRequestsTo': {