stackql-deploy 2.2.0

Infrastructure-as-code framework for declarative cloud resource management using StackQL
/*+ exists */
SELECT COUNT(*) as count FROM
(
    SELECT vpc_id,
    json_group_object(tag_key, tag_value) as tags
    FROM aws.ec2.vpc_tags
    WHERE region = '{{ region }}'
    AND cidr_block = '{{ cidr_block }}'
    GROUP BY vpc_id
    HAVING json_extract(tags, '$.Provisioner') = 'stackql'
    AND json_extract(tags, '$.StackName') = '{{ stack_name }}'
    AND json_extract(tags, '$.StackEnv') = '{{ stack_env }}'
) t 

/*+ create */
INSERT INTO aws.ec2.vpcs (
 CidrBlock,
 Tags,
 EnableDnsSupport,
 EnableDnsHostnames, 
 ClientToken,
 region
)
SELECT 
 '{{ cidr_block }}',
 '{{ tags }}',
 true,
 true,
 '{{ idempotency_token }}',
 '{{ region }}'

/*+ statecheck, retries=3, retry_delay=5 */
SELECT COUNT(*) as count FROM
(
    SELECT vpc_id,
    json_group_object(tag_key, tag_value) as tags
    FROM aws.ec2.vpc_tags
    WHERE region = '{{ region }}'
    AND cidr_block = '{{ cidr_block }}'
    GROUP BY vpc_id
    HAVING json_extract(tags, '$.Provisioner') = 'stackql'
    AND json_extract(tags, '$.StackName') = '{{ stack_name }}'
    AND json_extract(tags, '$.StackEnv') = '{{ stack_env }}'
) t 

/*+ exports, retries=3, retry_delay=5 */
SELECT vpc_id,
json_group_object(tag_key, tag_value) as tags
FROM aws.ec2.vpc_tags
WHERE region = '{{ region }}'
AND cidr_block = '{{ cidr_block }}'
GROUP BY vpc_id
HAVING json_extract(tags, '$.Provisioner') = 'stackql'
AND json_extract(tags, '$.StackName') = '{{ stack_name }}'
AND json_extract(tags, '$.StackEnv') = '{{ stack_env }}'

/*+ delete */
DELETE FROM aws.ec2.vpcs
WHERE Identifier = '{{ vpc_id}}'
AND region = '{{ region }}';