Exemple #1
0
def create_service(mocked_config):
    os.chdir(f'{TEST_DIR}/dummy')
    with patch.object(ServiceConfiguration, 'edit_config',
                      new=mocked_config):
        with patch.object(ServiceConfiguration, 'get_config',
                          new=mocked_config):
            ServiceCreator(service_name, environment_name, "env.sample").create()
Exemple #2
0
def create_service(name, environment, version, build_arg, dockerfile,
                   env_sample_file, ssh, cache_from):
    ServiceCreator(name, environment, env_sample_file).create(
        version=version,
        build_arg=dict(build_arg),
        dockerfile=dockerfile,
        ssh=ssh,
        cache_from=list(cache_from),
    )
Exemple #3
0
def test_cloudlift_can_deploy_to_fargate(keep_resources):
    cfn_client = boto3.client('cloudformation')
    stack_name = f'{fargate_service_name}-{environment_name}'
    cfn_client.delete_stack(StackName=stack_name)
    print("initiated delete of " + stack_name)
    waiter = cfn_client.get_waiter('stack_delete_complete')
    waiter.wait(StackName=stack_name)
    print("completed delete")
    config_path = '/'.join([environment_name, fargate_service_name, 'env.properties'])
    os.chdir('./test/dummy')
    print("adding configuration to parameter store")
    ssm_client = boto3.client('ssm')
    ssm_client.put_parameter(
        Name=f"/{environment_name}/{fargate_service_name}/PORT",
        Value="80",
        Type="SecureString",
        KeyId='alias/aws/ssm', Overwrite=True
    )
    ssm_client.put_parameter(
        Name=f"/{environment_name}/{fargate_service_name}/LABEL",
        Value="Demo",
        Type="SecureString",
        KeyId='alias/aws/ssm',
        Overwrite=True
    )
    with patch.object(ServiceConfiguration, 'edit_config',
                     new=mocked_fargate_service_config):
        with patch.object(ServiceConfiguration, 'get_config',
                          new=mocked_fargate_service_config):
            ServiceCreator(fargate_service_name, environment_name,).create()
    ServiceUpdater(fargate_service_name, environment_name, None).run()
    outputs = cfn_client.describe_stacks(
        StackName=stack_name
    )['Stacks'][0]['Outputs']
    service_url = [
        x for x in outputs if x["OutputKey"] == "DummyFargateServiceURL"
    ][0]['OutputValue']
    content_matched = wait_until(
        lambda: match_page_content(
            service_url,
            'This is dummy app. Label: Demo'
        ), 60)
    os.chdir('../../')
    assert content_matched
    if not keep_resources:
        cfn_client.delete_stack(StackName=stack_name)
Exemple #4
0
def update_service(name, environment, env_sample_file):
    ServiceCreator(name, environment, env_sample_file).update()
Exemple #5
0
def update_service(name, environment):
    ServiceCreator(name, environment).update()
Exemple #6
0
def create_service(name, environment):
    ServiceCreator(name, environment).create()