forked from kseebaldt/sample_glue_pipelines
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add path secrets and fix permissions
- Loading branch information
Showing
14 changed files
with
157 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
def transform_raw(secrets, spark, glueContext): | ||
def transform_raw(paths, secrets, spark, glueContext): | ||
df = ( | ||
spark.read.format("csv") | ||
.option("header", True) | ||
.option("inferSchema", True) | ||
.load(f"{secrets['raw_path']}/sample/austin_traffic/") | ||
.load(f"{paths['raw_path']}/sample/austin_traffic/") | ||
) | ||
|
||
df.write.format("parquet").mode("overwrite").save( | ||
f"{secrets['stage_path']}/sample/austin_traffic/" | ||
f"{paths['stage_path']}/sample/austin_traffic/" | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
|
||
import boto3 | ||
from moto import mock_secretsmanager | ||
from pytest import fixture | ||
|
||
from sample_pipelines.driver import secrets | ||
|
||
|
||
@fixture(autouse=True) | ||
def mock_secrets(): | ||
os.environ["AWS_DEFAULT_REGION"] = "us-east-1" | ||
|
||
with mock_secretsmanager(): | ||
client = boto3.client("secretsmanager", region_name="us-east-1") | ||
yield client | ||
|
||
|
||
@fixture() | ||
def paths_key(mock_secrets): | ||
key = "my-paths" | ||
mock_secrets.create_secret( | ||
Name=key, | ||
SecretString='{"raw_path": "s3://abc/123"}', | ||
) | ||
return key | ||
|
||
|
||
def test_returns_parsed_secrets(paths_key): | ||
result = secrets(paths_key) | ||
assert result == {"raw_path": "s3://abc/123"} | ||
|
||
|
||
def test_returns_empty_dict_when_key_is_not_found(): | ||
result = secrets("other") | ||
assert result == {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,8 @@ | |
"s3:PutObject" | ||
], | ||
"Resource": [ | ||
"arn:aws:s3:::${data_bucket}*" | ||
"arn:aws:s3:::${data_bucket}/*" | ||
] | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.