Skip to content

Commit de9f0ad

Browse files
committed
fixing data source
1 parent f90e9e6 commit de9f0ad

File tree

3 files changed

+121
-4
lines changed

3 files changed

+121
-4
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
uses: docker/build-push-action@v6
4141
with:
4242
push: ${{ github.event_name != 'pull_request' }}
43-
tags: ${{ steps.meta.outputs.tags }}
43+
tags: "${{ steps.meta.outputs.tags }} ${{ github.sha }}"
4444
labels: ${{ steps.meta.outputs.labels }}
4545

4646
deploy-cloudformation:
@@ -65,4 +65,9 @@ jobs:
6565
role-session-name: Deploy
6666

6767
- name: Deploy stack
68-
run: sam deploy
68+
run: >
69+
sam deploy --parameter-overrides
70+
SubnetIds=subnet-d30953b4,subnet-3b103115
71+
VpcId=vpc-27ccbb5d
72+
ImageTag=${{ github.sha }}
73+
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
select *
2-
from 'https://data.iowa.gov/resource/cyqb-8ina.csv?fiscal_year=2020&fiscal_year_period=1&$limit=1000000000'
3-
-- from '/Users/prowe/Development/modern-data-stack/jaffle_shop_duckdb/checkbook.csv'
2+
-- from 'https://data.iowa.gov/resource/cyqb-8ina.csv?fiscal_year=2020&fiscal_year_period=1&$limit=1000000000'
3+
from './checkbook.csv'

template.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
AWSTemplateFormatVersion: '2010-09-09'
22
Description: DuckLake stack managed by DBT (Paul)
3+
Transform: AWS::Serverless-2016-10-31
34

45
Parameters:
56
SubnetIds:
@@ -8,6 +9,9 @@ Parameters:
89
VpcId:
910
Type: AWS::EC2::VPC::Id
1011
Description: VPC ID for the Database
12+
ImageTag:
13+
Type: String
14+
Description: The tag of the Docker image to use for the DBT container
1115

1216
Resources:
1317
LakeBucket:
@@ -54,6 +58,114 @@ Resources:
5458
CapacityProviders:
5559
- FARGATE
5660

61+
LogGroup:
62+
Type: AWS::Logs::LogGroup
63+
Properties:
64+
RetentionInDays: 30
65+
66+
ECSTaskExecutionRole:
67+
Type: AWS::IAM::Role
68+
Properties:
69+
AssumeRolePolicyDocument:
70+
Statement:
71+
- Effect: Allow
72+
Principal:
73+
Service: [ecs-tasks.amazonaws.com]
74+
Action: ['sts:AssumeRole']
75+
Condition:
76+
ArnLike:
77+
aws:SourceArn: !Sub arn:aws:ecs:${AWS::Region}:${AWS::AccountId}:*
78+
StringEquals:
79+
aws:SourceAccount: !Ref AWS::AccountId
80+
Path: /
81+
ManagedPolicyArns:
82+
- arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
83+
Policies:
84+
- PolicyName: LakeBucketFullAccess
85+
PolicyDocument:
86+
Version: "2012-10-17"
87+
Statement:
88+
- Effect: Allow
89+
Action:
90+
- s3:PutObject
91+
- s3:GetObject
92+
- s3:DeleteObject
93+
- s3:ListBucket
94+
- s3:GetBucketLocation
95+
- s3:PutObjectAcl
96+
- s3:GetObjectAcl
97+
Resource:
98+
- !Sub "${LakeBucket.Arn}"
99+
- !Sub "${LakeBucket.Arn}/*"
100+
- Effect: Allow
101+
Action:
102+
- secretsmanager:GetSecretValue
103+
Resource: !GetAtt PostgresDB.MasterUserSecret.SecretArn
104+
105+
106+
DataTransformTaskDefinition:
107+
Type: AWS::ECS::TaskDefinition
108+
Properties:
109+
Family: DataTransform
110+
Cpu: 1024
111+
Memory: 8192
112+
NetworkMode: awsvpc
113+
RequiresCompatibilities:
114+
- FARGATE
115+
ExecutionRoleArn: !GetAtt ECSTaskExecutionRole.Arn
116+
TaskRoleArn: !GetAtt ECSTaskExecutionRole.Arn
117+
RuntimePlatform:
118+
CpuArchitecture: X86_64
119+
ContainerDefinitions:
120+
- Name: dbt
121+
Cpu: 1024
122+
Memory: 8192
123+
Image: !Sub "ghcr.io/sourceallies/duck-lake-example:${ImageTag}"
124+
LogConfiguration:
125+
LogDriver: awslogs
126+
Options:
127+
awslogs-group: !Ref LogGroup
128+
awslogs-region: !Ref AWS::Region
129+
awslogs-stream-prefix: dbt
130+
Command: [run]
131+
Environment:
132+
- Name: PGHOST
133+
Value: !GetAtt PostgresDB.Endpoint.Address
134+
- Name: PGPORT
135+
Value: !GetAtt PostgresDB.Endpoint.Port
136+
- Name: DATA_S3_PATH
137+
Value: !Sub "s3://${LakeBucket}/data/"
138+
Secrets:
139+
- Name: PGUSER
140+
ValueFrom: !Sub "${PostgresDB.MasterUserSecret.SecretArn}:username::"
141+
- Name: PGPASSWORD
142+
ValueFrom: !Sub "${PostgresDB.MasterUserSecret.SecretArn}:password::"
143+
144+
DataTransformStateMachine:
145+
Type: AWS::Serverless::StateMachine
146+
Properties:
147+
Definition:
148+
StartAt: RunDataTransformTask
149+
States:
150+
RunDataTransformTask:
151+
Type: Task
152+
Resource: arn:aws:states:::ecs:runTask.sync
153+
Parameters:
154+
Cluster: !Ref Cluster
155+
TaskDefinition: !Ref DataTransformTaskDefinition
156+
LaunchType: FARGATE
157+
NetworkConfiguration:
158+
AwsvpcConfiguration:
159+
Subnets:
160+
- !Select [ 0, !Ref SubnetIds ]
161+
- !Select [ 1, !Ref SubnetIds ]
162+
AssignPublicIp: ENABLED
163+
SecurityGroups:
164+
- !GetAtt PublicDBSecurityGroup.GroupId
165+
End: true
166+
Policies:
167+
- AmazonECS_FullAccess
168+
57169
Outputs:
58170
DBEndpoint:
59171
Description: The connection endpoint for the PostgreSQL instance

0 commit comments

Comments
 (0)