SELECT * FROM iasql_install('<modules>');
SELECT generate_put_ecr_image_build_spec('us-west-2', 'latest', 'my-repository', 'myrepouri.com', 'examples/ecs-fargate/prisma/app');
SELECT generate_put_ecr_image_build_spec('us-west-2', 'latest', 'my-repository', 'myrepouri.com', 'examples/ecs-fargate/prisma/app', array['IASQL_ENV=local', 'SECRET=secret']);
SELECT * FROM import_source_credential('<region>', '<GH_PAT>', 'GITHUB', 'PERSONAL_ACCESS_TOKEN');
SELECT *
FROM source_credentials_list
WHERE source_type = 'GITHUB';
DELETE FROM source_credentials_list
WHERE source_type = 'GITHUB';
INSERT INTO repository (repository_name)
VALUES ('<dbAlias>');
INSERT INTO iam_role (role_name, assume_role_policy_document, attached_policies_arns)
VALUES ('<dbAlias>', '<assumeServicePolicy>', array ['arn:aws:iam::aws:policy/CloudWatchLogsFullAccess',
'arn:aws:iam::aws:policy/AWSCodeBuildAdminAccess',
'arn:aws:iam::aws:policy/AWSCodeStarFullAccess',
'arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess']);
INSERT INTO codebuild_project (project_name, source_type, service_role_name)
VALUES ('<dbAlias>-codepipeline', 'CODEPIPELINE', '<dbAlias>');
SELECT *
FROM codebuild_project
WHERE project_name='<dbAlias>-codepipeline';
DELETE FROM codebuild_project WHERE project_name='<dbAlias>-codepipeline';
SELECT * FROM start_build('<dbAlias>', '<region>');
SELECT * FROM codebuild_build_list
WHERE project_name = '<dbAlias>';
INSERT INTO codebuild_project (project_name, build_spec, source_type, privileged_mode, service_role_name)
VALUES ('<dbAlias>-push-ecr', 'version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws ecr get-login-password --region<region>| docker login --username AWS --password-stdin ' || (SELECT repository_uri FROM repository WHERE repository_name = '<dbAlias>' ) || '
build:
commands:
- echo Building the Docker image...
- docker pull public.ecr.aws/docker/library/ubuntu:latest
- docker tag public.ecr.aws/docker/library/ubuntu:latest ' || (SELECT repository_uri FROM repository WHERE repository_name = '<dbAlias>' ) || ':latest
post_build:
commands:
- echo Pushing the Docker image...
- docker push ' || (SELECT repository_uri FROM repository WHERE repository_name = '<dbAlias>' ) || ':latest', 'NO_SOURCE', true, '<dbAlias>');
SELECT * FROM start_build('<dbAlias>-push-ecr', '<region>');
SELECT * FROM codebuild_build_list
WHERE project_name = '<dbAlias>-push-ecr' AND build_status='SUCCEEDED';
SELECT *
FROM repository_image
WHERE private_repository_id = (SELECT id FROM repository WHERE repository_name = '<dbAlias>');
DELETE
FROM repository_image
WHERE private_repository_id = (SELECT id FROM repository WHERE repository_name = '<dbAlias>');
DELETE FROM codebuild_build_list
WHERE project_name in ('<dbAlias>', '<dbAlias>-push-ecr');
DELETE FROM codebuild_project
WHERE project_name in ('<dbAlias>', '<dbAlias>-push-ecr');
DELETE FROM repository
WHERE repository_name = '<dbAlias>';
DELETE FROM iam_role
WHERE role_name = '<dbAlias>';