質問編集履歴

2

ソースコードが正常に表示されるように更新しました。

2023/05/11 00:17

投稿

btm2023
btm2023

スコア1

test CHANGED
File without changes
test CHANGED
@@ -47,18 +47,16 @@
47
47
  }
48
48
  ]
49
49
 
50
- # filter the instances based on filters() above
50
+
51
51
  instances = ec2.instances.filter(Filters=filters)
52
52
 
53
- # instantiate empty array
54
53
  StoppedInstances = []
55
54
 
56
55
  for instance in instances:
57
- # for each instance, append to array and print instance id
56
+
58
57
  StoppedInstances.append(instance.id)
59
58
  print (instance.id)
60
59
 
61
- # 一致ありの場合はインスタンスID一覧で停止
62
60
  if len(response['Reservations']) <= 0:
63
61
 
64
62
  instance_ids = []
@@ -68,7 +66,7 @@
68
66
 
69
67
  print('[+] stop ec2 on region "%s"' % region['RegionName'])
70
68
  print(response)
71
- # 一致ありの場合はスキップ
69
+
72
70
  continue
73
71
 
74
72
  stop_ec2()

1

エラー内容を追記しました。

2023/05/11 00:15

投稿

btm2023
btm2023

スコア1

test CHANGED
File without changes
test CHANGED
@@ -10,13 +10,24 @@
10
10
  Environmentというタグが01のサーバにてrunningステータスのものが一台もない場合は、
11
11
  Environmentタグ02のサーバをすべて停止したいと考えております。
12
12
 
13
- ### 発生している問題・エラーメッセージ
14
13
 
14
+ ###調査したこと・試したこと
15
15
  https://tex2e.github.io/blog/infrastructure/aws-stop-ec2
16
16
 
17
17
  こちらのページのスクリプトを参考に、コードを作成していますが、エラーが発生しており
18
18
  どう直せばいいかわからない状態です。
19
19
  やりたいことに沿う形で直し方がわかる方がいらっしゃればご教示下さい。
20
+
21
+ ### 発生している問題・エラーメッセージ
22
+
23
+ {
24
+ "errorMessage": "Syntax error in module 'lambda_function': unindent does not match any outer indentation level (lambda_function.py, line 19)",
25
+ "errorType": "Runtime.UserCodeSyntaxError",
26
+ "stackTrace": [
27
+ " File \"/var/task/lambda_function.py\" Line 19\n instances = ec2.instances.filter(Filters=filters)\n"
28
+ ]
29
+ }
30
+
20
31
 
21
32
  ### 該当のソースコード
22
33
  import boto3