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.

53 lines
1.4 KiB

  1. import boto3
  2. ################################################################################################
  3. #
  4. # Configuration Parameters
  5. #
  6. ################################################################################################
  7. # place your credentials in ~/.aws/credentials, as mentioned in AWS Educate Classroom,
  8. # Account Details, AWC CLI -> Show (Copy and paste the following into ~/.aws/credentials)
  9. # !!! you also need to specify an IAM role for this example to able to access S3 !!!
  10. # region = 'eu-central-1'
  11. region = 'us-east-1'
  12. stackName = 'cloudcomp-counter-demo-stack'
  13. keyName = 'srieger-pub'
  14. ################################################################################################
  15. #
  16. # boto3 code
  17. #
  18. ################################################################################################
  19. client = boto3.setup_default_session(region_name=region)
  20. cfClient = boto3.client('cloudformation')
  21. templateFile = open("cloudcomp-counter-demo-with-vpc.json", "r")
  22. templateBody = templateFile.read()
  23. print("Deleting old stack...")
  24. print("------------------------------------")
  25. response = cfClient.delete_stack(
  26. StackName=stackName,
  27. )
  28. print("creating new stack...")
  29. print("------------------------------------")
  30. response = cfClient.create_stack(
  31. StackName=stackName,
  32. TemplateBody=templateBody,
  33. Parameters=[
  34. {
  35. 'ParameterKey': 'paramKeyPair',
  36. 'ParameterValue': keyName
  37. },
  38. ],
  39. )