mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-17 04:59:37 -04:00
Merge pull request #694 from GSA/switch-to-fips
Switch to using FIPS-enabled endpoints
This commit is contained in:
@@ -1,7 +1,18 @@
|
|||||||
import botocore
|
import botocore
|
||||||
from boto3 import Session
|
from boto3 import Session
|
||||||
|
from botocore.config import Config
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
|
AWS_CLIENT_CONFIG = Config(
|
||||||
|
# This config is required to enable S3 to connect to FIPS-enabled
|
||||||
|
# endpoints. See https://aws.amazon.com/compliance/fips/ for more
|
||||||
|
# information.
|
||||||
|
s3={
|
||||||
|
'addressing_style': 'virtual',
|
||||||
|
},
|
||||||
|
use_fips_endpoint=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_s3_object(
|
def get_s3_object(
|
||||||
bucket_name,
|
bucket_name,
|
||||||
@@ -11,8 +22,12 @@ def get_s3_object(
|
|||||||
region,
|
region,
|
||||||
):
|
):
|
||||||
# To inspect contents: obj.get()['Body'].read().decode('utf-8')
|
# To inspect contents: obj.get()['Body'].read().decode('utf-8')
|
||||||
session = Session(aws_access_key_id=access_key, aws_secret_access_key=secret_key, region_name=region)
|
session = Session(
|
||||||
s3 = session.resource('s3')
|
aws_access_key_id=access_key,
|
||||||
|
aws_secret_access_key=secret_key,
|
||||||
|
region_name=region
|
||||||
|
)
|
||||||
|
s3 = session.resource('s3', config=AWS_CLIENT_CONFIG)
|
||||||
obj = s3.Object(bucket_name, filename)
|
obj = s3.Object(bucket_name, filename)
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user