You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.0 KiB

  1. import boto3
  2. ################################################################################################
  3. #
  4. # Configuration Parameters
  5. #
  6. ################################################################################################
  7. # region = 'eu-central-1'
  8. region = 'us-east-1'
  9. stackName = 'cloudcomp-counter-demo-stack'
  10. keyName = 'srieger-pub'
  11. # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  12. # !!!
  13. # !!! You must change vpc, subnet and availability zone below to match your zone, or use the
  14. # !!! start-with-vpc.py example, that creates and looks up all depedencies / necessary
  15. # !!! resources.
  16. # !!!
  17. # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  18. ################################################################################################
  19. #
  20. # boto3 code
  21. #
  22. ################################################################################################
  23. client = boto3.setup_default_session(region_name=region)
  24. cfClient = boto3.client('cloudformation')
  25. templateFile = open("cloudcomp-counter-demo.json", "r")
  26. templateBody = templateFile.read()
  27. print("Deleting old stack...")
  28. print("------------------------------------")
  29. response = cfClient.delete_stack(
  30. StackName=stackName,
  31. )
  32. print("creating new stack...")
  33. print("------------------------------------")
  34. response = cfClient.create_stack(
  35. StackName=stackName,
  36. TemplateBody=templateBody,
  37. Parameters=[
  38. {
  39. 'ParameterKey': 'paramKeyPair',
  40. 'ParameterValue': keyName
  41. },
  42. {
  43. 'ParameterKey': 'paramVPC',
  44. 'ParameterValue': 'vpc-eedd4187'
  45. },
  46. {
  47. 'ParameterKey': 'paramAvailabilityZones',
  48. 'ParameterValue': 'eu-central-1a, eu-central-1b, eu-central-1c',
  49. },
  50. {
  51. 'ParameterKey': 'paramSubnetIDs',
  52. 'ParameterValue': 'subnet-5c5f6d16, subnet-41422b28, subnet-6f2ea214',
  53. },
  54. ],
  55. )