Jedes Mal, wenn ich zum ersten Mal der folgenden Terraforming-Datei ausführen kann ich den Fehler:Ungültige Haupt in Politik
Fehler IAM Rolle SecurityMonkey erstellen: MalformedPolicyDocument: Ungültige Haupt in der Politik: „AWS“.
Allerdings führe ich den Code die ein zweites Mal die Ausführung erfolgreich erstellen die Übernahme Rolle Objekt. Für mich sieht es so aus, als gäbe es Probleme mit Abhängigkeiten zwischen Rolle A und Rolle B. Als Abhilfe habe ich sogar eine depends_on-Anweisung auf die Rolle A gesetzt, aber ohne Glück.
SecurityMonkeyInstanceProfile
Hier können Sie meine TF-Code überprüfen.
resource "aws_iam_role" "SecurityMonkey" {
name = "SecurityMonkey"
depends_on = ["aws_iam_role.SecurityMonkeyInstanceProfile"]
path = "/"
assume_role_policy = <<POLICY
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<AccountID>:role/SecurityMonkeyInstanceProfile"
},
"Action": "sts:AssumeRole"
}
]
}
POLICY
}
resource "aws_iam_role" "SecurityMonkeyInstanceProfile" {
name = "SecurityMonkeyInstanceProfile"
path = "/"
assume_role_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
POLICY
}
Zuerst mit Fehler ausführen.
aws_iam_role.SecurityMonkey: Error creating IAM Role SecurityMonkey: MalformedPolicyDocument: Invalid principal in policy: "AWS":"arn:aws:iam::<AccountID>:role/SecurityMonkeyInstanceProfile"
status code: 400, request id: 0810c923-28dd-11e6-af5d-47689d50861a
Zweiter Lauf ohne Fehler.
terraform apply -var-file=../../aws.tfvars
aws_iam_role.SecurityMonkeyInstanceProfile: Refreshing state... (ID: SecurityMonkeyInstanceProfile)
aws_iam_role.SecurityMonkey: Creating...
arn: "" => "<computed>"
assume_role_policy: "" => "{\n \"Version\": \"2008-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::<AccountID>:role/SecurityMonkeyInstanceProfile\"\n },\n \"Action\": \"sts:AssumeRole\"\n }\n ]\n}\n"
name: "" => "SecurityMonkey"
path: "" => "/"
unique_id: "" => "<computed>"
aws_iam_role.SecurityMonkey: Creation complete
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Klar, dass die Ressourcen in der richtigen Reihenfolge erstellt, aber scheint es eine Art Timeout ist die SecurityMonkeyInstanceProfile
Rolle nicht auffindbar durch SecurityMonkey
Rolle spielt. So ziemlich ein Problem mit Huhn und Ei.
Irgendwelche Hinweise?
Hallo, Dank für Ihre Antwort. Ich habe den Schlafbefehl ohne Erfolg ausprobiert, noch bevor ich die Frage zu SO gestellt habe. Jedenfalls habe ich ein Problem auf Github, https://github.com/hashicorp/terraform/issues/7076 angesprochen –