{
  "AWSTemplateFormatVersion": "2010-09-09",
  	"Parameters": {
  		"parEc2KeyPair": {
      		"NoEcho": "false",
      		"Description" : "EC2 Key Pair of the database client",
      		"Type": "String"
      	},
	    "parS3Bucket": {
	    	"NoEcho": "false",
	    	"Description" : "S3 bucket containing scripts, templates and binaries",
	    	"Type": "String"
		},
	    "parLambdaRoleARN": {
	    	"NoEcho": "false",
	    	"Description" : "ex. arn:aws:iam::<account_id>:role/<role_name>",
	    	"Type": "String"
		},
	    "parRDSMonitoringRoleARN": {
	    	"NoEcho": "false",
	    	"Description" : "ex. arn:aws:iam::<account_id>:role/<role_name>",
	    	"Type": "String"
		},
	    "parSnsTopic": {
	    	"NoEcho": "false",
	    	"Description" : "SNS Topic for notifications. It needs an e-mail subscriber",
	    	"Type": "String"
		},
	    "parDbPassword": {
	      "NoEcho": "true",
	      "Description" : "The master username password",
	      "Type": "String",
	      "MinLength": "8",
	      "MaxLength": "16",
	      "AllowedPattern" : "[a-zA-Z0-9]*",
	      "ConstraintDescription" : "Must contain only alphanumeric characters"
	    	}
	},
    "Resources": {
		"SecurityStack": {
			"Type": "AWS::CloudFormation::Stack",
			"Properties": {
		 		"TemplateURL": "https://s3.amazonaws.com/alexards-virginia-bucket-2019/templates/alexards_security.template"	
		 	}
		},
		"NetworkStack": {
			"Type": "AWS::CloudFormation::Stack",
			"Properties": {
		 		"TemplateURL": "https://s3.amazonaws.com/alexards-virginia-bucket-2019/templates/alexards_network.template"
			}
		},
		"StorageStack": {
			"Type": "AWS::CloudFormation::Stack",
			"Properties": {
		 		"TemplateURL": "https://s3.amazonaws.com/alexards-virginia-bucket-2019/templates/alexards_storage.template",
		 		"Parameters": {
					"parDbPassword": { "Ref" : "parDbPassword" },
					"parSnsTopic": { "Ref" : "parSnsTopic" }
				}
			}
		},
		"ComputeStack": {
			"Type": "AWS::CloudFormation::Stack",
			"Properties": {
				"Parameters": {
					"myPublicSubnet1": { "Fn::GetAtt": ["NetworkStack", "Outputs.myPublicSubnet1"] },
					"myBastionSecGrp": { "Fn::GetAtt": ["NetworkStack", "Outputs.myBastionSecGrp"] },
					"myDBOracleSecGrp": { "Fn::GetAtt": ["NetworkStack", "Outputs.myDBOracleSecGrp"] },
					"myBastionInstProf": { "Fn::GetAtt": ["SecurityStack", "Outputs.myBastionInstProf"] },
					"myRDSParamGroup": { "Fn::GetAtt": ["StorageStack", "Outputs.myRDSParamGroup"] },
					"parEc2KeyPair": { "Ref" : "parEc2KeyPair" },
					"parS3Bucket": { "Ref" : "parS3Bucket" },
					"parRDSMonitoringRoleARN": { "Ref" : "parRDSMonitoringRoleARN" },
					"parLambdaRoleARN": { "Ref" : "parLambdaRoleARN" },
					"parDbPassword": { "Ref" : "parDbPassword" }
				},
		 		"TemplateURL": "https://s3.amazonaws.com/alexards-virginia-bucket-2019/templates/alexards_compute.template"
			}	
		}
   },
  "Description": "alexards_global"
}