Skip to content

Commit 133efa1

Browse files
committed
debug bucket replication
1 parent 62e8aa9 commit 133efa1

File tree

5 files changed

+31
-18
lines changed

5 files changed

+31
-18
lines changed

code/fixtf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,15 @@ def fixtf(ttft,tf):
279279
if ttft=="aws_s3_bucket_replication_configuration":
280280
for t1 in Lines:
281281
t1=t1.strip()
282-
if globals.debug5: print("DEBUG5: pre scan block: t1=", t1)
282+
if globals.debug5: print("DEBUG5: pre scan block1 : t1=", t1)
283283
skip=0
284284
tt1=t1.split("=")[0].strip()
285285
if tt1=="bucket":
286286
try:
287287
tt2=t1.split("=")[1].strip().strip('\"')
288288
if "arn:aws:s3" in tt2:
289289
tt2=tt2.split(":")[-1]
290-
if globals.debug5: print("DEBUG5: pre scan block: common.add_dep bucket_name=", tt2)
290+
if globals.debug5: print("DEBUG5: pre scan block 2: common.add_dep bucket_name=", tt2)
291291
common.add_dependancy("aws_s3_bucket", tt2)
292292
except:
293293
tt2=""

code/fixtf_aws_resources/aws_common.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,39 @@ def aws_common(type,t1,tt1,tt2,flag1,flag2):
4040
common.add_dependancy("aws_apigatewayv2_api", tt2)
4141
#if tt1=="bucket" or tt1=="s3_bucket_name" or tt1=="bucket_name":
4242
if tt1=="bucket" or tt1=="s3_bucket_name":
43-
#if globals.debug5: print("DEBUG5: aws_common: type=", type, "tt1=", tt1, "tt2=", tt2)
43+
if globals.debug5: print("DEBUG5: aws_common: type=", type, "tt1=", tt1, "tt2=", tt2)
4444
if type != "aws_s3_bucket":
4545
if "." not in tt2:
4646
if tt2 != "" and tt2 !="null":
47-
if tt2.startswith("arn:aws:s3"): tt2=tt2.split(":")[-1]
4847
if globals.debug5:
4948
print("DEBUG5: aws_common: bucket_name=", tt2)
5049
for k, v in globals.bucketlist.items():
5150
print("DEBUG5: aws_common: bucketlist k,v=",k,v)
52-
if tt2 == "":
53-
print("WARNING: bucket name from arn " +tt2 +" is empty")
54-
return skip,t1,flag1,flag2
55-
56-
try:
57-
if globals.bucketlist[tt2]:
58-
t1=tt1 + " = aws_s3_bucket.b-" + tt2 + ".bucket\n"
59-
#common.add_dependancy("aws_s3_bucket", tt2)
51+
52+
if tt2.startswith("arn:aws:s3"):
53+
tt2=tt2.split(":")[-1]
54+
try:
55+
if globals.bucketlist[tt2]:
56+
t1=tt1 + " = aws_s3_bucket.b-" + tt2 + ".arn\n"
57+
#common.add_dependancy("aws_s3_bucket", tt2)
58+
return skip,t1,flag1,flag2
59+
except KeyError as e:
6060
return skip,t1,flag1,flag2
61-
except KeyError as e:
62-
return skip,t1,flag1,flag2
61+
62+
else:
63+
try:
64+
if globals.bucketlist[tt2]:
65+
t1=tt1 + " = aws_s3_bucket.b-" + tt2 + ".bucket\n"
66+
#common.add_dependancy("aws_s3_bucket", tt2)
67+
return skip,t1,flag1,flag2
68+
except KeyError as e:
69+
return skip,t1,flag1,flag2
70+
71+
else:
72+
print("WARNING: bucket name from arn " +tt2 +" is empty or null")
73+
return skip,t1,flag1,flag2
74+
75+
6376

6477
if tt1.endswith("bucket_arn"):
6578
if globals.debug5: print("DEBUG5: aws_common: bucket_name=", tt2, "lhs=",tt1)

code/fixtf_aws_resources/fixtf_s3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ def aws_s3_bucket_replication_configuration(t1,tt1,tt2,flag1,flag2):
126126
if tt1 == "bucket" and "arn:aws:s3" in tt2:
127127
bn=tt2.split(":")[-1]
128128
if globals.debug5:
129-
print("-- aws_s3_bucket_replication_configuration: "+bn)
130-
print("-- " + str(globals.bucketlist))
129+
print("DEBUG5: fix aws_s3_bucket_replication_configuration: "+bn)
130+
print("DEBUG5: " + str(globals.bucketlist))
131131
try:
132132
if globals.bucketlist[bn]:
133133
t1=tt1 + " = aws_s3_bucket.b-" + bn + ".arn\n"

code/get_aws_resources/aws_s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def get_s3(s3_fields,type,bucket_name):
247247
try:
248248
#print("HERE ....")
249249
barn=str(response['ReplicationConfiguration']['Rules'][0]['Destination']['Bucket'])
250-
if globals.debug5: print("get_s3: replication bucket="+barn)
250+
#print("replication bucket="+barn)
251251
repbuck=barn.split(":")[-1]
252252
#print("replication bucket="+repbuck)
253253
common.add_known_dependancy("aws_s3_bucket",repbuck)

code/globals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys,os
22

3-
aws2tfver="v1011"
3+
aws2tfver="v1012"
44
tfver="5.100.0"
55
esttime=120.0
66
profile="default"

0 commit comments

Comments
 (0)