text stringlengths 0 14.1k |
|---|
tags = {key: str(value) for key, value in cfg.get(""tags"").items()} |
if tags != existing_cfg.get(""Tags""): |
if existing_cfg.get(""Tags""): |
client.untag_resource( |
Resource=ret[""FunctionArn""], |
TagKeys=list(existing_cfg[""Tags""].keys()), |
) |
client.tag_resource(Resource=ret[""FunctionArn""], Tags=tags) |
def upload_s3(cfg, path_to_zip_file, *use_s3): |
""""""Upload a function to AWS S3."""""" |
print(""Uploading your new Lambda function"") |
profile_name = cfg.get(""profile"") |
aws_access_key_id = cfg.get(""aws_access_key_id"") |
aws_secret_access_key = cfg.get(""aws_secret_access_key"") |
client = get_client( |
""s3"", |
profile_name, |
aws_access_key_id, |
aws_secret_access_key, |
cfg.get(""region""), |
) |
byte_stream = b"""" |
with open(path_to_zip_file, mode=""rb"") as fh: |
byte_stream = fh.read() |
s3_key_prefix = cfg.get(""s3_key_prefix"", ""/dist"") |
checksum = hashlib.new(""md5"", byte_stream).hexdigest() |
timestamp = str(time.time()) |
filename = ""{prefix}{checksum}-{ts}.zip"".format( |
prefix=s3_key_prefix, checksum=checksum, ts=timestamp, |
) |
# Do we prefer development variable over config? |
buck_name = os.environ.get(""S3_BUCKET_NAME"") or cfg.get(""bucket_name"") |
func_name = os.environ.get(""LAMBDA_FUNCTION_NAME"") or cfg.get( |
""function_name"" |
) |
kwargs = { |
""Bucket"": ""{}"".format(buck_name), |
""Key"": ""{}"".format(filename), |
""Body"": byte_stream, |
} |
client.put_object(**kwargs) |
print(""Finished uploading {} to S3 bucket {}"".format(func_name, buck_name)) |
if use_s3: |
return filename |
def get_function_config(cfg): |
""""""Check whether a function exists or not and return its config"""""" |
function_name = cfg.get(""function_name"") |
profile_name = cfg.get(""profile"") |
aws_access_key_id = cfg.get(""aws_access_key_id"") |
aws_secret_access_key = cfg.get(""aws_secret_access_key"") |
client = get_client( |
""lambda"", |
profile_name, |
aws_access_key_id, |
aws_secret_access_key, |
cfg.get(""region""), |
) |
try: |
return client.get_function(FunctionName=function_name) |
except client.exceptions.ResourceNotFoundException as e: |
if ""Function not found"" in str(e): |
return False |
def get_concurrency(cfg): |
""""""Return the Reserved Concurrent Executions if present in the config"""""" |
concurrency = int(cfg.get(""concurrency"", 0)) |
return max(0, concurrency) |
def read_cfg(path_to_config_file, profile_name): |
cfg = read(path_to_config_file, loader=yaml.full_load) |
if profile_name is not None: |
cfg[""profile""] = profile_name |
elif ""AWS_PROFILE"" in os.environ: |
cfg[""profile""] = os.environ[""AWS_PROFILE""] |
return cfg |
" isc |
datapipe/generator-bakery generators/cm-puppet/templates/build.sh 140 "#!/bin/bash |
DIR=""$( cd ""$( dirname ""${BASH_SOURCE[0]}"" )"" && pwd )"" |
packer build -var-file=""${DIR}/packer-vars.json"" ""${DIR}/packer.json"" |
" isc |
marten-de-vries/kneden test/fixtures/for-in/actual.js 79 "async function test(object) { |
for (var key in object) { |
await key; |
} |
} |
" isc |
mfil/getebook getebook/epub.py 25314 "# Copyright (c) 2015, Max Fillinger <max@max-fillinger.net> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.