Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ settings_local.py
# Distribution / packaging
.Python
env/
venv/
build/
cover/
develop-eggs/
Expand Down
6 changes: 3 additions & 3 deletions cloudformation/0_Main.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"AMILookup": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": "https://s3.amazonaws.com/cf-dynamic-execution-server/AMI_Lookup.json",
"TemplateURL": "https://cf-dynamic-execution-server.s3.amazonaws.com/AMI_Lookup.json",
"Parameters": {
"LookupLatestWindowsServerAmi": "False",
"LookupLatestCentosAmi": "True"
Expand All @@ -153,7 +153,7 @@
"VPCNAT": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": "https://s3.amazonaws.com/cf-dynamic-execution-server/1_VPC.json",
"TemplateURL": "https://cf-dynamic-execution-server.s3.amazonaws.com/1_VPC.json",
"Parameters": {
"VPCCIDR": {
"Ref": "1VPCCIDR"
Expand Down Expand Up @@ -265,7 +265,7 @@
"Ref": "8InstanceType"
}
},
"TemplateURL": "https://s3.amazonaws.com/cf-dynamic-execution-server/2_EC2.json"
"TemplateURL": "https://cf-dynamic-execution-server.s3.amazonaws.com/2_EC2.json"
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions cloudformation/0_Main_EX.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"AMILookup": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": "https://s3.amazonaws.com/cf-dynamic-execution-server/AMI_Lookup.json",
"TemplateURL": "https://cf-dynamic-execution-server.s3.amazonaws.com/AMI_Lookup.json",
"Parameters": {
"LookupLatestWindowsServerAmi": "False",
"LookupLatestCentosAmi": "True"
Expand All @@ -143,7 +143,7 @@
"VPCNAT": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": "https://s3.amazonaws.com/cf-dynamic-execution-server/1_VPC_EX.json",
"TemplateURL": "https://cf-dynamic-execution-server.s3.amazonaws.com/1_VPC_EX.json",
"Parameters": {
"VPCCIDR": {
"Ref": "1VPCCIDR"
Expand Down Expand Up @@ -245,7 +245,7 @@
"Ref": "8InstanceType"
}
},
"TemplateURL": "https://s3.amazonaws.com/cf-dynamic-execution-server/2_EC2_EX.json"
"TemplateURL": "https://cf-dynamic-execution-server.s3.amazonaws.com/2_EC2_EX.json"
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions cloudformation/0_Main_EX_No_VPN.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"AMILookup": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": "https://s3.amazonaws.com/cf-dynamic-execution-server/AMI_Lookup.json",
"TemplateURL": "https://cf-dynamic-execution-server.s3.amazonaws.com/AMI_Lookup.json",
"Parameters": {
"LookupLatestWindowsServerAmi": "True",
"LookupLatestCentosAmi": "True"
Expand All @@ -132,7 +132,7 @@
"VPCNAT": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": "https://s3.amazonaws.com/cf-dynamic-execution-server/1_VPC_EX_No_VPN.json",
"TemplateURL": "https://cf-dynamic-execution-server.s3.amazonaws.com/1_VPC_EX_No_VPN.json",
"Parameters": {
"VPCCIDR": {
"Ref": "1VPCCIDR"
Expand Down Expand Up @@ -244,7 +244,7 @@
"Ref": "7CloudShellServerInstanceType"
}
},
"TemplateURL": "https://s3.amazonaws.com/cf-dynamic-execution-server/2_EC2_EX_No_VPN.json"
"TemplateURL": "https://cf-dynamic-execution-server.s3.amazonaws.com/2_EC2_EX_No_VPN.json"
}
}
},
Expand Down
8 changes: 4 additions & 4 deletions cloudformation/2_EC2.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"echo 'nameserver 8.8.8.8' >> /etc/resolv.conf\n",
"echo 'nameserver 8.8.4.4' >> /etc/resolv.conf\n",
"chattr +i /etc/resolv.conf\n",
"curl https://s3.amazonaws.com/cf-dynamic-execution-server/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"curl https://cf-dynamic-execution-server.s3.amazonaws.com/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"chmod +rwx ./cloudshell_es_install_script.sh\n",
"sed -i -e 's/\r$//' ./cloudshell_es_install_script.sh\n",
"./cloudshell_es_install_script.sh ",
Expand Down Expand Up @@ -187,7 +187,7 @@
"echo 'nameserver 8.8.8.8' >> /etc/resolv.conf\n",
"echo 'nameserver 8.8.4.4' >> /etc/resolv.conf\n",
"chattr +i /etc/resolv.conf\n",
"curl https://s3.amazonaws.com/cf-dynamic-execution-server/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"curl https://cf-dynamic-execution-server.s3.amazonaws.com/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"chmod +rwx ./cloudshell_es_install_script.sh\n",
"sed -i -e 's/\r$//' ./cloudshell_es_install_script.sh\n",
"./cloudshell_es_install_script.sh ",
Expand Down Expand Up @@ -261,7 +261,7 @@
"echo 'nameserver 8.8.8.8' >> /etc/resolv.conf\n",
"echo 'nameserver 8.8.4.4' >> /etc/resolv.conf\n",
"chattr +i /etc/resolv.conf\n",
"curl https://s3.amazonaws.com/cf-dynamic-execution-server/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"curl https://cf-dynamic-execution-server.s3.amazonaws.com/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"chmod +rwx ./cloudshell_es_install_script.sh\n",
"sed -i -e 's/\r$//' ./cloudshell_es_install_script.sh\n",
"./cloudshell_es_install_script.sh ",
Expand Down Expand Up @@ -311,7 +311,7 @@
"echo 'nameserver 8.8.8.8' >> /etc/resolv.conf\n",
"echo 'nameserver 8.8.4.4' >> /etc/resolv.conf\n",
"chattr +i /etc/resolv.conf\n",
"curl https://s3.amazonaws.com/cf-dynamic-execution-server/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"curl https://cf-dynamic-execution-server.s3.amazonaws.com/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"chmod +rwx ./cloudshell_es_install_script.sh\n",
"sed -i -e 's/\r$//' ./cloudshell_es_install_script.sh\n",
"./cloudshell_es_install_script.sh ",
Expand Down
8 changes: 4 additions & 4 deletions cloudformation/2_EC2_EX.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
"echo 'nameserver 8.8.8.8' >> /etc/resolv.conf\n",
"echo 'nameserver 8.8.4.4' >> /etc/resolv.conf\n",
"chattr +i /etc/resolv.conf\n",
"curl https://s3.amazonaws.com/cf-dynamic-execution-server/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"curl https://cf-dynamic-execution-server.s3.amazonaws.com/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"chmod +rwx ./cloudshell_es_install_script.sh\n",
"sed -i -e 's/\r$//' ./cloudshell_es_install_script.sh\n",
"./cloudshell_es_install_script.sh ",
Expand Down Expand Up @@ -202,7 +202,7 @@
"echo 'nameserver 8.8.8.8' >> /etc/resolv.conf\n",
"echo 'nameserver 8.8.4.4' >> /etc/resolv.conf\n",
"chattr +i /etc/resolv.conf\n",
"curl https://s3.amazonaws.com/cf-dynamic-execution-server/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"curl https://cf-dynamic-execution-server.s3.amazonaws.com/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"chmod +rwx ./cloudshell_es_install_script.sh\n",
"sed -i -e 's/\r$//' ./cloudshell_es_install_script.sh\n",
"./cloudshell_es_install_script.sh ",
Expand Down Expand Up @@ -283,7 +283,7 @@
"echo 'nameserver 8.8.8.8' >> /etc/resolv.conf\n",
"echo 'nameserver 8.8.4.4' >> /etc/resolv.conf\n",
"chattr +i /etc/resolv.conf\n",
"curl https://s3.amazonaws.com/cf-dynamic-execution-server/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"curl https://cf-dynamic-execution-server.s3.amazonaws.com/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"chmod +rwx ./cloudshell_es_install_script.sh\n",
"sed -i -e 's/\r$//' ./cloudshell_es_install_script.sh\n",
"./cloudshell_es_install_script.sh ",
Expand Down Expand Up @@ -341,7 +341,7 @@
"echo 'nameserver 8.8.8.8' >> /etc/resolv.conf\n",
"echo 'nameserver 8.8.4.4' >> /etc/resolv.conf\n",
"chattr +i /etc/resolv.conf\n",
"curl https://s3.amazonaws.com/cf-dynamic-execution-server/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"curl https://cf-dynamic-execution-server.s3.amazonaws.com/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"chmod +rwx ./cloudshell_es_install_script.sh\n",
"sed -i -e 's/\r$//' ./cloudshell_es_install_script.sh\n",
"./cloudshell_es_install_script.sh ",
Expand Down
8 changes: 4 additions & 4 deletions cloudformation/2_EC2_EX_No_VPN.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"echo 'nameserver 8.8.8.8' >> /etc/resolv.conf\n",
"echo 'nameserver 8.8.4.4' >> /etc/resolv.conf\n",
"chattr +i /etc/resolv.conf\n",
"curl https://s3.amazonaws.com/cf-dynamic-execution-server/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"curl https://cf-dynamic-execution-server.s3.amazonaws.com/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"chmod +rwx ./cloudshell_es_install_script.sh\n",
"sed -i -e 's/\r$//' ./cloudshell_es_install_script.sh\n",
"./cloudshell_es_install_script.sh ",
Expand Down Expand Up @@ -218,7 +218,7 @@
"echo 'nameserver 8.8.8.8' >> /etc/resolv.conf\n",
"echo 'nameserver 8.8.4.4' >> /etc/resolv.conf\n",
"chattr +i /etc/resolv.conf\n",
"curl https://s3.amazonaws.com/cf-dynamic-execution-server/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"curl https://cf-dynamic-execution-server.s3.amazonaws.com/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"chmod +rwx ./cloudshell_es_install_script.sh\n",
"sed -i -e 's/\r$//' ./cloudshell_es_install_script.sh\n",
"./cloudshell_es_install_script.sh ",
Expand Down Expand Up @@ -303,7 +303,7 @@
"echo 'nameserver 8.8.8.8' >> /etc/resolv.conf\n",
"echo 'nameserver 8.8.4.4' >> /etc/resolv.conf\n",
"chattr +i /etc/resolv.conf\n",
"curl https://s3.amazonaws.com/cf-dynamic-execution-server/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"curl https://cf-dynamic-execution-server.s3.amazonaws.com/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"chmod +rwx ./cloudshell_es_install_script.sh\n",
"sed -i -e 's/\r$//' ./cloudshell_es_install_script.sh\n",
"./cloudshell_es_install_script.sh ",
Expand Down Expand Up @@ -365,7 +365,7 @@
"echo 'nameserver 8.8.8.8' >> /etc/resolv.conf\n",
"echo 'nameserver 8.8.4.4' >> /etc/resolv.conf\n",
"chattr +i /etc/resolv.conf\n",
"curl https://s3.amazonaws.com/cf-dynamic-execution-server/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"curl https://cf-dynamic-execution-server.s3.amazonaws.com/execution-server/cloudshell_es_install_script.sh --output cloudshell_es_install_script.sh --retry 20 -s -S\n",
"chmod +rwx ./cloudshell_es_install_script.sh\n",
"sed -i -e 's/\r$//' ./cloudshell_es_install_script.sh\n",
"./cloudshell_es_install_script.sh ",
Expand Down
2 changes: 1 addition & 1 deletion cloudformation/publish_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def main():
if obj.key in uploaded_keys:
# Make all the uploaded files public
obj.Acl().put(ACL='public-read')
print "https://s3.amazonaws.com/{}/{}".format(bucket_name, obj.key)
print "https://{}.s3.amazonaws.com/{}".format(bucket_name, obj.key)


def get_s3_key(folder, specs_file):
Expand Down
2 changes: 1 addition & 1 deletion drivers/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.3
2.4.7.1
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def deploy(self, ec2_session, s3_session, name, reservation, aws_ec2_cp_resource
"""
ami_deployment_model = ami_deploy_action.actionParams.deployment.customModel
vpc = self.vpc_service.find_vpc_for_reservation(ec2_session=ec2_session,
reservation_id=reservation.reservation_id)
reservation_id=reservation.reservation_id, logger=logger)
if not vpc:
raise ValueError('VPC is not set for this reservation')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def cleanup(self, ec2_client, ec2_session, s3_session, aws_ec2_data_model, reser
try:
# need to remove the keypair before we try to find the VPC
self._remove_keypair(aws_ec2_data_model, ec2_session, logger, reservation_id, s3_session)
vpc = self.vpc_service.find_vpc_for_reservation(ec2_session, reservation_id)
vpc = self.vpc_service.find_vpc_for_reservation(ec2_session, reservation_id, logger)

if not vpc:
raise ValueError('No VPC was created for this reservation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def _prepare_network(self, ec2_client, ec2_session, reservation, aws_ec2_datamod
# will get or create a vpc for the reservation
self.cancellation_service.check_if_cancelled(cancellation_context)
logger.info("Get or create existing VPC (no subnets yet)")
vpc = self._get_or_create_vpc(cidr, ec2_session, reservation)
vpc = self._get_or_create_vpc(cidr, ec2_session, reservation, logger)

# will enable dns for the vpc
self.cancellation_service.check_if_cancelled(cancellation_context)
Expand Down Expand Up @@ -363,13 +363,15 @@ def _get_or_create_sandbox_isolated_security_group(self, ec2_session, management

return security_group

def _get_or_create_vpc(self, cidr, ec2_session, reservation):
def _get_or_create_vpc(self, cidr, ec2_session, reservation, logger):
vpc = self.vpc_service.find_vpc_for_reservation(ec2_session=ec2_session,
reservation_id=reservation.reservation_id)
reservation_id=reservation.reservation_id,
logger = logger)
if not vpc:
vpc = self.vpc_service.create_vpc_for_reservation(ec2_session=ec2_session,
reservation=reservation,
cidr=cidr)
cidr=cidr,
logger = logger)
return vpc
def _create_prepare_create_keys_result(self, action, access_key):
action_result = CreateKeysActionResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def execute(self, subnet_actions):
action_items = [PrepareSubnetExecutor.ActionItem(a) for a in subnet_actions]

# get vpc and availability_zone
vpc = self.vpc_service.find_vpc_for_reservation(ec2_session=self.ec2_session, reservation_id=self.reservation.reservation_id)
vpc = self.vpc_service.find_vpc_for_reservation(ec2_session=self.ec2_session, reservation_id=self.reservation.reservation_id, logger=self.logger)

if not vpc:
vpcs_count = self.vpc_service.get_active_vpcs_count(self.ec2_client, self.logger)
Expand Down
9 changes: 6 additions & 3 deletions package/cloudshell/cp/aws/domain/services/ec2/vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, tag_service, subnet_service, instance_service, vpc_waiter, vp
self.route_table_service = route_table_service
self.traffic_mirror_service = traffic_mirror_service

def create_vpc_for_reservation(self, ec2_session, reservation, cidr):
def create_vpc_for_reservation(self, ec2_session, reservation, cidr, logger):
"""
Will create a vpc for reservation and will save it in a folder in the s3 bucket
:param ec2_session: Ec2 Session
Expand All @@ -51,6 +51,7 @@ def create_vpc_for_reservation(self, ec2_session, reservation, cidr):
:return: vpc
"""
vpc = ec2_session.create_vpc(CidrBlock=cidr)
logger.info("Created VPC for reservation {0}. Id is {1}".format(reservation.reservation_id, vpc.id))

self.vpc_waiter.wait(vpc=vpc, state=self.vpc_waiter.AVAILABLE)

Expand Down Expand Up @@ -104,18 +105,20 @@ def get_or_create_private_route_table(self, ec2_session, reservation, vpc_id):
route_table_name)
return route_table

def find_vpc_for_reservation(self, ec2_session, reservation_id):
def find_vpc_for_reservation(self, ec2_session, reservation_id, logger):
filters = [{'Name': 'tag:Name',
'Values': [self.VPC_RESERVATION.format(reservation_id)]}]

vpcs = list(ec2_session.vpcs.filter(Filters=filters))

if not vpcs:
logger.info("No VPC found for reservation {0}".format(reservation_id))
return None

if len(vpcs) > 1:
raise ValueError('Too many vpcs for the reservation')

logger.info("VPC found for reservation {0}. Id is {1}".format(reservation_id, vpcs[0].id))
return vpcs[0]

def peer_vpcs(self, ec2_session, vpc_id1, vpc_id2, reservation_model, logger):
Expand All @@ -133,7 +136,7 @@ def peer_vpcs(self, ec2_session, vpc_id1, vpc_id2, reservation_model, logger):
"""

# create peering connection
logger.info("Creating VPC Peering between {0} to {1} ".format(vpc_id1, vpc_id1))
logger.info("Creating VPC Peering between {0} to {1}".format(vpc_id1, vpc_id2))
vpc_peer_connection = ec2_session.create_vpc_peering_connection(VpcId=vpc_id1, PeerVpcId=vpc_id2)
logger.info(
"VPC Peering created {0} ,State : {1} ".format(vpc_peer_connection.id, vpc_peer_connection.status['Code']))
Expand Down
2 changes: 1 addition & 1 deletion package/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.3
2.4.7.1
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.3
2.4.7.1