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.

58 lines
1.6 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. keyName = 'vockey'
  15. roleName = 'LabRole'
  16. ################################################################################################
  17. #
  18. # boto3 code
  19. #
  20. ################################################################################################
  21. client = boto3.setup_default_session(region_name=region)
  22. cfClient = boto3.client('cloudformation')
  23. templateFile = open("cloudcomp-counter-demo-with-vpc.json", "r")
  24. templateBody = templateFile.read()
  25. print("Deleting old stack...")
  26. print("------------------------------------")
  27. response = cfClient.delete_stack(
  28. StackName=stackName,
  29. )
  30. print("creating new stack...")
  31. print("------------------------------------")
  32. response = cfClient.create_stack(
  33. StackName=stackName,
  34. TemplateBody=templateBody,
  35. Parameters=[
  36. {
  37. 'ParameterKey': 'paramKeyPair',
  38. 'ParameterValue': keyName
  39. },
  40. {
  41. 'ParameterKey': 'paramIamInstanceRole',
  42. 'ParameterValue': roleName
  43. },
  44. ],
  45. )