MDR Terraform Notes.txt 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ------------------
  2. workspaces are being used to break up environments.
  3. terraform workspace list
  4. terraform workspace select test
  5. Strange errors? Unexpected results? try this
  6. rm .terraform
  7. terraform init
  8. State issues
  9. terraform state show aws_ami.msoc_base
  10. terraform refresh -target=data.aws_ami.msoc_base
  11. Terraform also has a DynamoDB State lock (msoc-terraform-lock). This will prevent terraform state breakage.
  12. ------------------
  13. View TF code
  14. https://github.com/terraform-aws-modules
  15. -------------------
  16. Modules
  17. We are using the aws ec2-instance module
  18. https://registry.terraform.io/modules/terraform-aws-modules/ec2-instance/aws/2.13.0
  19. https://github.com/terraform-aws-modules/terraform-aws-ec2-instance
  20. var.something means this is a module that needs the variable to run. Your code will fill the variable.
  21. data is a read-only terrafom object that queries provider or generates something on the localhost
  22. locals are variables that can refer to variables or other locals
  23. variables - expecting data from somewhere else.
  24. provider instance of the API
  25. --------------------
  26. IAM Role
  27. get this error?
  28. aws_iam_policy.nga_instance_policy: Error creating IAM policy nga_instance_tag_read: AccessDenied:
  29. add this
  30. provider = "aws.iam_admin"
  31. -------------------
  32. in terraform .tf files when the self = true. that is for putting the security group into itself. e.g. add the security group to the security groups rules.
  33. the terraform is setup in folders. each folder is a project and apply should be run in the folder. Common is the execption as some of the projects are dependent on that folder.
  34. role and policy have to be done in the IAM terraform
  35. iam_data.tf
  36. 02-msoc_vpc/lambda.tf with security groups
  37. terraform plan -target=
  38. terraform plan -target=module.sensu_go_server.aws_instance.this -target=module.sensu_go_server.aws_route53_record.private
  39. terraform apply -target=module.sensu_server.aws_route53_record.private -target=module.sensu_server.aws_instance.this
  40. terraform apply -target=aws_security_group_rule.outbound_to_sensu -target=module.sensu_servers_sg.aws_security_group_rule.ingress_with_cidr_blocks[0] -target=module.sensu_servers_sg.aws_security_group_rule.ingress_with_cidr_blocks[1]
  41. terraform apply -target=module.vpc_default_security_groups.aws_security_group_rule.typical_host_outbound_to_sensu_8081 -target=aws_security_group_rule.vault_server_to_sensu -target=module.vpc_default_security_groups.aws_security_group_rule.typical_host_outbound_to_sensu_5672
  42. terraform apply -target=module.afs_cluster.module.vpc_default_security_groups.aws_security_group_rule.typical_host_outbound_to_sensu_5672 -target=module.afs_cluster.module.vpc_default_security_groups.aws_security_group_rule.typical_host_outbound_to_sensu_8081