How to use create_tags method in localstack

Best Python code snippet using localstack_python

TagChecker.py

Source:TagChecker.py Github

copy

Full Screen

...50 51 # replace the names with the IAM User name of the same52 if requester == 'Rejith' or requester == 'Larry' or requester == 'Lucas':53 if tagValue == 'AppID':54 response = client.create_tags(55 Resources=[56 Inst,57 ],58 Tags=[59 {60 'Key': tagValue,61 'Value': 'SYSID-00611'62 }63 ]64 )65 elif tagValue == 'Environment':66 response = client.create_tags(67 Resources=[68 Inst,69 ],70 Tags=[71 {72 'Key': tagValue,73 'Value': 'Dev'74 }75 ]76 )77 elif tagValue == 'Criticality':78 response = client.create_tags(79 Resources=[80 Inst,81 ],82 Tags=[83 {84 'Key': tagValue,85 'Value': 'Tier3'86 }87 ]88 )89 elif tagValue == 'Support':90 response = client.create_tags(91 Resources=[92 Inst,93 ],94 Tags=[95 {96 'Key': tagValue,97 'Value': 'DL-DigitalDocker@citizensbank.com'98 }99 ]100 )101 elif tagValue == 'BusinessUnit':102 response = client.create_tags(103 Resources=[104 Inst,105 ],106 Tags=[107 {108 'Key': tagValue,109 'Value': '66201'110 }111 ]112 )113 elif tagValue == 'CostCenter':114 response = client.create_tags(115 Resources=[116 Inst,117 ],118 Tags=[119 {120 'Key': tagValue,121 'Value': '23404'122 }123 ]124 )125 else:126 pass127 elif requester == 'LInda' or requester == 'Raul' or requester == 'John' or requester == 'Hanish':128 if tagValue == 'AppID':129 response = client.create_tags(130 Resources=[131 Inst,132 ],133 Tags=[134 {135 'Key': tagValue,136 'Value': 'SYSID-05602'137 }138 ]139 )140 elif tagValue == 'Environment':141 response = client.create_tags(142 Resources=[143 Inst,144 ],145 Tags=[146 {147 'Key': tagValue,148 'Value': 'Dev'149 }150 ]151 )152 elif tagValue == 'Criticality':153 response = client.create_tags(154 Resources=[155 Inst,156 ],157 Tags=[158 {159 'Key': tagValue,160 'Value': 'Tier3'161 }162 ]163 )164 elif tagValue == 'Support':165 response = client.create_tags(166 Resources=[167 Inst,168 ],169 Tags=[170 {171 'Key': tagValue,172 'Value': 'CTP'173 }174 ]175 )176 elif tagValue == 'BusinessUnit':177 response = client.create_tags(178 Resources=[179 Inst,180 ],181 Tags=[182 {183 'Key': tagValue,184 'Value': '51042'185 }186 ]187 )188 elif tagValue == 'CostCenter':189 response = client.create_tags(190 Resources=[191 Inst,192 ],193 Tags=[194 {195 'Key': tagValue,196 'Value': '22503'197 }198 ]199 )200 else:201 pass202 else:203 pass204 205 if len(notFoundTag) != 0:206 msg.append('Tags not found: '+str(notFoundTag))207 208 for tags in notFoundTag:209 print tags210 msg.append('\n')211 else:212 pass213 tagValue=[]214 except:215 msg.append('No Tag found for Instance: '+Inst+'\n')216 217 response = client.describe_snapshots(OwnerIds=[218 'self',219 ])220 for snapshot in response['Snapshots']:221 snapshotid = snapshot['SnapshotId']222 try:223 for tag in snapshot['Tags']:224 for i in range(len(TAG)):225 if TAG[i] in tag['Key']:226 truetags.append(tag['Key'])227 if tag['Value'] == '':228 tagValue.append(tag['Key'])229 except:230 print 'No tags found in ',snapshotid231 232 notFoundTag = list(set(TAG)-set(truetags))233 truetags=[]234 if len(tagValue) != 0 or len(notFoundTag) != 0:235 # msg.append('Creator: '+str(emailId))236 msg.append('Snapshot Id: '+str(snapshotid))237 238 if len(tagValue) != 0:239 msg.append('No values found for Tag: '+str(tagValue))240 241 # replace the names with the IAM User name of the same242 if requester == 'Rejith' or requester == 'Larry' or requester == 'Lucas':243 if tagValue == 'AppID':244 response = client.create_tags(245 Resources=[246 Inst,247 ],248 Tags=[249 {250 'Key': tagValue,251 'Value': 'SYSID-00611'252 }253 ]254 )255 elif tagValue == 'Environment':256 response = client.create_tags(257 Resources=[258 Inst,259 ],260 Tags=[261 {262 'Key': tagValue,263 'Value': 'Dev'264 }265 ]266 )267 elif tagValue == 'Criticality':268 response = client.create_tags(269 Resources=[270 Inst,271 ],272 Tags=[273 {274 'Key': tagValue,275 'Value': 'Tier3'276 }277 ]278 )279 elif tagValue == 'Support':280 response = client.create_tags(281 Resources=[282 Inst,283 ],284 Tags=[285 {286 'Key': tagValue,287 'Value': 'DL-DigitalDocker@citizensbank.com'288 }289 ]290 )291 elif tagValue == 'BusinessUnit':292 response = client.create_tags(293 Resources=[294 Inst,295 ],296 Tags=[297 {298 'Key': tagValue,299 'Value': '66201'300 }301 ]302 )303 elif tagValue == 'CostCenter':304 response = client.create_tags(305 Resources=[306 Inst,307 ],308 Tags=[309 {310 'Key': tagValue,311 'Value': '23404'312 }313 ]314 )315 else:316 pass317 elif requester == 'LInda' or requester == 'Raul' or requester == 'John' or requester == 'Hanish':318 if tagValue == 'AppID':319 response = client.create_tags(320 Resources=[321 Inst,322 ],323 Tags=[324 {325 'Key': tagValue,326 'Value': 'SYSID-05602'327 }328 ]329 )330 elif tagValue == 'Environment':331 response = client.create_tags(332 Resources=[333 Inst,334 ],335 Tags=[336 {337 'Key': tagValue,338 'Value': 'Dev'339 }340 ]341 )342 elif tagValue == 'Criticality':343 response = client.create_tags(344 Resources=[345 Inst,346 ],347 Tags=[348 {349 'Key': tagValue,350 'Value': 'Tier3'351 }352 ]353 )354 elif tagValue == 'Support':355 response = client.create_tags(356 Resources=[357 Inst,358 ],359 Tags=[360 {361 'Key': tagValue,362 'Value': 'CTP'363 }364 ]365 )366 elif tagValue == 'BusinessUnit':367 response = client.create_tags(368 Resources=[369 Inst,370 ],371 Tags=[372 {373 'Key': tagValue,374 'Value': '51042'375 }376 ]377 )378 elif tagValue == 'CostCenter':379 response = client.create_tags(380 Resources=[381 Inst,382 ],383 Tags=[384 {385 'Key': tagValue,386 'Value': '22503'387 }388 ]389 )390 else:391 pass392 else:393 pass394 395 if len(notFoundTag) != 0:396 msg.append('Tags not found: '+str(notFoundTag))397 398 msg.append('\n')399 else:400 pass401 tagValue=[]402 403 response = client.describe_images(Owners=[404 'self',405 ])406 for image in response['Images']:407 amiId = image['ImageId']408 for tag in image['Tags']:409 for i in range(len(TAG)):410 if TAG[i] in tag['Key']:411 truetags.append(tag['Key'])412 if tag['Value'] == '':413 tagValue.append(tag['Key'])414 415 notFoundTag = list(set(TAG)-set(truetags))416 truetags=[]417 if len(tagValue) != 0 or len(notFoundTag) != 0:418 # msg.append('Creator: '+str(emailId))419 msg.append('AMI Id: '+str(amiId))420 421 if len(tagValue) != 0:422 msg.append('No values found for Tag: '+str(tagValue))423 424 # replace the names with the IAM User name of the same425 if requester == 'Rejith' or requester == 'Larry' or requester == 'Lucas':426 if tagValue == 'AppID':427 response = client.create_tags(428 Resources=[429 Inst,430 ],431 Tags=[432 {433 'Key': tagValue,434 'Value': 'SYSID-00611'435 }436 ]437 )438 elif tagValue == 'Environment':439 response = client.create_tags(440 Resources=[441 Inst,442 ],443 Tags=[444 {445 'Key': tagValue,446 'Value': 'Dev'447 }448 ]449 )450 elif tagValue == 'Criticality':451 response = client.create_tags(452 Resources=[453 Inst,454 ],455 Tags=[456 {457 'Key': tagValue,458 'Value': 'Tier3'459 }460 ]461 )462 elif tagValue == 'Support':463 response = client.create_tags(464 Resources=[465 Inst,466 ],467 Tags=[468 {469 'Key': tagValue,470 'Value': 'DL-DigitalDocker@citizensbank.com'471 }472 ]473 )474 elif tagValue == 'BusinessUnit':475 response = client.create_tags(476 Resources=[477 Inst,478 ],479 Tags=[480 {481 'Key': tagValue,482 'Value': '66201'483 }484 ]485 )486 elif tagValue == 'CostCenter':487 response = client.create_tags(488 Resources=[489 Inst,490 ],491 Tags=[492 {493 'Key': tagValue,494 'Value': '23404'495 }496 ]497 )498 else:499 pass500 elif requester == 'LInda' or requester == 'Raul' or requester == 'John' or requester == 'Hanish':501 if tagValue == 'AppID':502 response = client.create_tags(503 Resources=[504 Inst,505 ],506 Tags=[507 {508 'Key': tagValue,509 'Value': 'SYSID-05602'510 }511 ]512 )513 elif tagValue == 'Environment':514 response = client.create_tags(515 Resources=[516 Inst,517 ],518 Tags=[519 {520 'Key': tagValue,521 'Value': 'Dev'522 }523 ]524 )525 elif tagValue == 'Criticality':526 response = client.create_tags(527 Resources=[528 Inst,529 ],530 Tags=[531 {532 'Key': tagValue,533 'Value': 'Tier3'534 }535 ]536 )537 elif tagValue == 'Support':538 response = client.create_tags(539 Resources=[540 Inst,541 ],542 Tags=[543 {544 'Key': tagValue,545 'Value': 'CTP'546 }547 ]548 )549 elif tagValue == 'BusinessUnit':550 response = client.create_tags(551 Resources=[552 Inst,553 ],554 Tags=[555 {556 'Key': tagValue,557 'Value': '51042'558 }559 ]560 )561 elif tagValue == 'CostCenter':562 response = client.create_tags(563 Resources=[564 Inst,565 ],566 Tags=[567 {568 'Key': tagValue,569 'Value': '22503'570 }571 ]572 )573 else:574 pass575 else:576 pass577 if len(notFoundTag) != 0:578 msg.append('Tags not found: '+str(notFoundTag))579 580 msg.append('\n')581 else:582 pass583 tagValue=[]584 585 response = client.describe_volumes()586 for volume in response['Volumes']:587 VolumeId = volume['VolumeId']588 for tag in volume['Tags']:589 for i in range(len(TAG)):590 if TAG[i] in tag['Key']:591 truetags.append(tag['Key'])592 if tag['Value'] == '':593 tagValue.append(tag['Key'])594 595 notFoundTag = list(set(TAG)-set(truetags))596 truetags=[]597 if len(tagValue) != 0 or len(notFoundTag) != 0:598 # msg.append('Creator: '+str(emailId))599 msg.append('Volume Id: '+str(VolumeId))600 601 if len(tagValue) != 0:602 msg.append('No values found for Tag: '+str(tagValue))603 604 605 # replace the names with the IAM User name of the same606 if requester == 'Rejith' or requester == 'Larry' or requester == 'Lucas':607 if tagValue == 'AppID':608 response = client.create_tags(609 Resources=[610 Inst,611 ],612 Tags=[613 {614 'Key': tagValue,615 'Value': 'SYSID-00611'616 }617 ]618 )619 elif tagValue == 'Environment':620 response = client.create_tags(621 Resources=[622 Inst,623 ],624 Tags=[625 {626 'Key': tagValue,627 'Value': 'Dev'628 }629 ]630 )631 elif tagValue == 'Criticality':632 response = client.create_tags(633 Resources=[634 Inst,635 ],636 Tags=[637 {638 'Key': tagValue,639 'Value': 'Tier3'640 }641 ]642 )643 elif tagValue == 'Support':644 response = client.create_tags(645 Resources=[646 Inst,647 ],648 Tags=[649 {650 'Key': tagValue,651 'Value': 'DL-DigitalDocker@citizensbank.com'652 }653 ]654 )655 elif tagValue == 'BusinessUnit':656 response = client.create_tags(657 Resources=[658 Inst,659 ],660 Tags=[661 {662 'Key': tagValue,663 'Value': '66201'664 }665 ]666 )667 elif tagValue == 'CostCenter':668 response = client.create_tags(669 Resources=[670 Inst,671 ],672 Tags=[673 {674 'Key': tagValue,675 'Value': '23404'676 }677 ]678 )679 else:680 pass681 elif requester == 'LInda' or requester == 'Raul' or requester == 'John' or requester == 'Hanish':682 if tagValue == 'AppID':683 response = client.create_tags(684 Resources=[685 Inst,686 ],687 Tags=[688 {689 'Key': tagValue,690 'Value': 'SYSID-05602'691 }692 ]693 )694 elif tagValue == 'Environment':695 response = client.create_tags(696 Resources=[697 Inst,698 ],699 Tags=[700 {701 'Key': tagValue,702 'Value': 'Dev'703 }704 ]705 )706 elif tagValue == 'Criticality':707 response = client.create_tags(708 Resources=[709 Inst,710 ],711 Tags=[712 {713 'Key': tagValue,714 'Value': 'Tier3'715 }716 ]717 )718 elif tagValue == 'Support':719 response = client.create_tags(720 Resources=[721 Inst,722 ],723 Tags=[724 {725 'Key': tagValue,726 'Value': 'CTP'727 }728 ]729 )730 elif tagValue == 'BusinessUnit':731 response = client.create_tags(732 Resources=[733 Inst,734 ],735 Tags=[736 {737 'Key': tagValue,738 'Value': '51042'739 }740 ]741 )742 elif tagValue == 'CostCenter':743 response = client.create_tags(744 Resources=[745 Inst,746 ],747 Tags=[748 {749 'Key': tagValue,750 'Value': '22503'751 }752 ]753 )754 else:755 pass756 else:757 pass758 if len(notFoundTag) != 0:759 msg.append('Tags not found: '+str(notFoundTag))760 761 msg.append('\n')762 else:763 pass764 tagValue=[]765 766 TAG = list(set(TAG)-set(['Name']))767 768 response = s3.list_buckets()769 for bucket in response['Buckets']:770 bucket = bucket['Name']771 try:772 response = s3.get_bucket_tagging(773 Bucket=bucket774 )775 for tag in response['TagSet']:776 for i in range(len(TAG)):777 if TAG[i] in tag['Key']:778 truetags.append(tag['Key'])779 if tag['Value'] == '':780 tagValue.append(tag['Key'])781 782 notFoundTag = list(set(TAG)-set(truetags))783 truetags=[]784 if len(tagValue) != 0 or len(notFoundTag) != 0:785 # msg.append('Creator: '+str(emailId))786 msg.append('S3 bucket: '+str(bucket))787 788 if len(tagValue) != 0:789 msg.append('No values found for Tag: '+str(tagValue))790 791 # replace the names with the IAM User name of the same792 if requester == 'Rejith' or requester == 'Larry' or requester == 'Lucas':793 if tagValue == 'AppID':794 response = client.create_tags(795 Resources=[796 Inst,797 ],798 Tags=[799 {800 'Key': tagValue,801 'Value': 'SYSID-00611'802 }803 ]804 )805 elif tagValue == 'Environment':806 response = client.create_tags(807 Resources=[808 Inst,809 ],810 Tags=[811 {812 'Key': tagValue,813 'Value': 'Dev'814 }815 ]816 )817 elif tagValue == 'Criticality':818 response = client.create_tags(819 Resources=[820 Inst,821 ],822 Tags=[823 {824 'Key': tagValue,825 'Value': 'Tier3'826 }827 ]828 )829 elif tagValue == 'Support':830 response = client.create_tags(831 Resources=[832 Inst,833 ],834 Tags=[835 {836 'Key': tagValue,837 'Value': 'DL-DigitalDocker@citizensbank.com'838 }839 ]840 )841 elif tagValue == 'BusinessUnit':842 response = client.create_tags(843 Resources=[844 Inst,845 ],846 Tags=[847 {848 'Key': tagValue,849 'Value': '66201'850 }851 ]852 )853 elif tagValue == 'CostCenter':854 response = client.create_tags(855 Resources=[856 Inst,857 ],858 Tags=[859 {860 'Key': tagValue,861 'Value': '23404'862 }863 ]864 )865 else:866 pass867 elif requester == 'LInda' or requester == 'Raul' or requester == 'John' or requester == 'Hanish':868 if tagValue == 'AppID':869 response = client.create_tags(870 Resources=[871 Inst,872 ],873 Tags=[874 {875 'Key': tagValue,876 'Value': 'SYSID-05602'877 }878 ]879 )880 elif tagValue == 'Environment':881 response = client.create_tags(882 Resources=[883 Inst,884 ],885 Tags=[886 {887 'Key': tagValue,888 'Value': 'Dev'889 }890 ]891 )892 elif tagValue == 'Criticality':893 response = client.create_tags(894 Resources=[895 Inst,896 ],897 Tags=[898 {899 'Key': tagValue,900 'Value': 'Tier3'901 }902 ]903 )904 elif tagValue == 'Support':905 response = client.create_tags(906 Resources=[907 Inst,908 ],909 Tags=[910 {911 'Key': tagValue,912 'Value': 'CTP'913 }914 ]915 )916 elif tagValue == 'BusinessUnit':917 response = client.create_tags(918 Resources=[919 Inst,920 ],921 Tags=[922 {923 'Key': tagValue,924 'Value': '51042'925 }926 ]927 )928 elif tagValue == 'CostCenter':929 response = client.create_tags(930 Resources=[931 Inst,932 ],933 Tags=[934 {935 'Key': tagValue,936 'Value': '22503'937 }938 ]939 )940 else:941 pass942 else:943 pass944 if len(notFoundTag) != 0:945 msg.append('Tags not found: '+str(notFoundTag))946 947 msg.append('\n')948 else:949 pass950 tagValue=[]951 except:952 print 'No TagSet'953 954 response = cfn.describe_stacks()955 for stack in response['Stacks']:956 stackName = stack['StackName']957 958 for tag in stack['Tags']:959 for i in range(len(TAG)):960 if TAG[i] in tag['Key']:961 truetags.append(tag['Key'])962 if tag['Value'] == '':963 tagValue.append(tag['Key'])964 965 notFoundTag = list(set(TAG)-set(truetags))966 truetags=[]967 if len(tagValue) != 0 or len(notFoundTag) != 0:968 # msg.append('Creator: '+str(emailId))969 msg.append('Stack Name: '+str(stackName))970 971 if len(tagValue) != 0:972 msg.append('No values found for Tag: '+str(tagValue))973 974 # replace the names with the IAM User name of the same975 if requester == 'Rejith' or requester == 'Larry' or requester == 'Lucas':976 if tagValue == 'AppID':977 response = client.create_tags(978 Resources=[979 Inst,980 ],981 Tags=[982 {983 'Key': tagValue,984 'Value': 'SYSID-00611'985 }986 ]987 )988 elif tagValue == 'Environment':989 response = client.create_tags(990 Resources=[991 Inst,992 ],993 Tags=[994 {995 'Key': tagValue,996 'Value': 'Dev'997 }998 ]999 )1000 elif tagValue == 'Criticality':1001 response = client.create_tags(1002 Resources=[1003 Inst,1004 ],1005 Tags=[1006 {1007 'Key': tagValue,1008 'Value': 'Tier3'1009 }1010 ]1011 )1012 elif tagValue == 'Support':1013 response = client.create_tags(1014 Resources=[1015 Inst,1016 ],1017 Tags=[1018 {1019 'Key': tagValue,1020 'Value': 'DL-DigitalDocker@citizensbank.com'1021 }1022 ]1023 )1024 elif tagValue == 'BusinessUnit':1025 response = client.create_tags(1026 Resources=[1027 Inst,1028 ],1029 Tags=[1030 {1031 'Key': tagValue,1032 'Value': '66201'1033 }1034 ]1035 )1036 elif tagValue == 'CostCenter':1037 response = client.create_tags(1038 Resources=[1039 Inst,1040 ],1041 Tags=[1042 {1043 'Key': tagValue,1044 'Value': '23404'1045 }1046 ]1047 )1048 else:1049 pass1050 elif requester == 'LInda' or requester == 'Raul' or requester == 'John' or requester == 'Hanish':1051 if tagValue == 'AppID':1052 response = client.create_tags(1053 Resources=[1054 Inst,1055 ],1056 Tags=[1057 {1058 'Key': tagValue,1059 'Value': 'SYSID-05602'1060 }1061 ]1062 )1063 elif tagValue == 'Environment':1064 response = client.create_tags(1065 Resources=[1066 Inst,1067 ],1068 Tags=[1069 {1070 'Key': tagValue,1071 'Value': 'Dev'1072 }1073 ]1074 )1075 elif tagValue == 'Criticality':1076 response = client.create_tags(1077 Resources=[1078 Inst,1079 ],1080 Tags=[1081 {1082 'Key': tagValue,1083 'Value': 'Tier3'1084 }1085 ]1086 )1087 elif tagValue == 'Support':1088 response = client.create_tags(1089 Resources=[1090 Inst,1091 ],1092 Tags=[1093 {1094 'Key': tagValue,1095 'Value': 'CTP'1096 }1097 ]1098 )1099 elif tagValue == 'BusinessUnit':1100 response = client.create_tags(1101 Resources=[1102 Inst,1103 ],1104 Tags=[1105 {1106 'Key': tagValue,1107 'Value': '51042'1108 }1109 ]1110 )1111 elif tagValue == 'CostCenter':1112 response = client.create_tags(1113 Resources=[1114 Inst,1115 ],1116 Tags=[1117 {1118 'Key': tagValue,1119 'Value': '22503'1120 }1121 ]1122 )1123 else:1124 pass1125 else:1126 pass...

Full Screen

Full Screen

setup-multi-az-vpc-from-scratch-using-boto.py

Source:setup-multi-az-vpc-from-scratch-using-boto.py Github

copy

Full Screen

...83 GroupName='pvtSecGrp',84 Description='Private_Security_Group',85 VpcId= vpc.id86 )87elbSecGrp.create_tags( Tags = globalVars['tags'] )88pubSecGrp.create_tags( Tags = globalVars['tags'] )89pvtSecGrp.create_tags( Tags = globalVars['tags'] )90elbSecGrp.create_tags(Tags=[{'Key': 'Name' ,'Value': globalVars['Project']['Value']+'-elb-security-group'}])91pubSecGrp.create_tags(Tags=[{'Key': 'Name' ,'Value': globalVars['Project']['Value']+'-public-security-group'}])92pvtSecGrp.create_tags(Tags=[{'Key': 'Name' ,'Value': globalVars['Project']['Value']+'-private-security-group'}])93# Add a rule that allows inbound SSH, HTTP, HTTPS traffic ( from any source )94ec2Client.authorize_security_group_ingress( GroupId = elbSecGrp.id ,95 IpProtocol= 'tcp',96 FromPort=80,97 ToPort=80,98 CidrIp='0.0.0.0/0'99 )100# Allow Public Security Group to receive traffic from ELB Security group101ec2Client.authorize_security_group_ingress( GroupId = pubSecGrp.id,102 IpPermissions = [{'IpProtocol': 'tcp',103 'FromPort': 80,104 'ToPort': 80,105 'UserIdGroupPairs': [{ 'GroupId':elbSecGrp.id}]106 }]...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful