
--MARS-757
set verify off
SET serveroutput ON
--SET TIMING ON
whenever sqlerror exit sql.sqlcode rollback;
column owner format a15
column object_name format a30
column spoolname new_value spoolname 
select 'install_package_MarsDEVOreplicator_MARS757_dev' || name || '_' ||to_char(sysdate,'YYYYMMDD_HH24MISS')||'.log' spoolname from v$pdbs;
spool '&spoolname'
prompt ##### started at time #####
select systimestamp from dual;
prompt ##### database name #####
select name pdb_name from v$pdbs;
--set echo on
--=============================================================================================================================
-- start install --MARS-757 dev setup
--=============================================================================================================================

BEGIN
    DBMS_CLOUD_ADMIN.ENABLE_PRINCIPAL_AUTH(
        provider => 'AWS',
        params => JSON_OBJECT(
                'aws_role_arn' value 'arn:aws:iam::303413094647:role/ECB_AWS_EXTERNAL_A2A_MRDS_LAB'));
END;
/

GRANT EXECUTE ON DBMS_CLOUD_ADMIN TO MRDS_LOADER;
GRANT EXECUTE ON AWS$ARN TO MRDS_LOADER;

BEGIN
   DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
         --host => 'oci-test-sani.vpce-0b3a5f000733397b0-kxlyoh5z.s3.eu-central-1.vpce.amazonaws.com',
         host => 'vpce-06c333350ae20060d-m2roqwbl.s3.eu-central-1.vpce.amazonaws.com',
         ace => xs$ace_type( privilege_list => xs$name_list('http'),
                             principal_name => 'ADMIN',
                             principal_type => xs_acl.ptype_db),
                             private_target => TRUE);
END;
/

BEGIN
   DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
         host => 'sts.eu-central-1.amazonaws.com',
         ace => xs$ace_type( privilege_list => xs$name_list('http'),
                             principal_name => 'ADMIN',
                             principal_type => xs_acl.ptype_db),
                             private_target => TRUE);
END;