Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1214 from mozilla-services/feat/1201
Browse files Browse the repository at this point in the history
feat: hardcode autopush_rs's AWS creds in local dynamodb mode
  • Loading branch information
bbangert authored May 7, 2018
2 parents 8075079 + 6865ded commit a520338
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 100 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ install:
- pip install tox ${CODECOV:+codecov}
- if [ ${WITH_RUST:-true} != "false" ]; then curl https://sh.rustup.rs | sh -s -- -y || travis_terminate 1; fi
- export PATH=$PATH:$HOME/.cargo/bin
- export AWS_SHARED_CREDENTIALS_FILE=./automock/boto.cfg
- export BOTO_CONFIG=./automock/boto.cfg
script:
- tox -- ${CODECOV:+--with-coverage --cover-xml --cover-package=autopush}
after_success:
Expand Down
46 changes: 0 additions & 46 deletions Dockerfile.automock

This file was deleted.

15 changes: 0 additions & 15 deletions automock/boto.cfg

This file was deleted.

16 changes: 0 additions & 16 deletions automock/supervisord.conf

This file was deleted.

1 change: 1 addition & 0 deletions autopush_rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions autopush_rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ openssl = "0.10.5"
regex = "0.2"
reqwest = { version = "0.8.5", features = ["unstable"] }
rusoto_core = "0.32.0"
rusoto_credential = "0.11.0"
rusoto_dynamodb = "0.32.0"
sentry = "0.2.0"
serde = "1.0.45"
Expand Down
1 change: 1 addition & 0 deletions autopush_rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ extern crate openssl;
extern crate regex;
extern crate reqwest;
extern crate rusoto_core;
extern crate rusoto_credential;
extern crate rusoto_dynamodb;
extern crate sentry;
extern crate serde;
Expand Down
30 changes: 18 additions & 12 deletions autopush_rs/src/util/ddb_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use futures::future;
use futures_backoff::retry_if;
use regex::RegexSet;
use rusoto_core::Region;
use rusoto_core::reactor::RequestDispatcher;
use rusoto_credential::StaticProvider;
use rusoto_dynamodb::{AttributeValue, DynamoDb, DynamoDbClient, QueryError, QueryInput,
UpdateItemError, UpdateItemInput, UpdateItemOutput};
use serde_dynamodb;
Expand Down Expand Up @@ -292,20 +294,24 @@ pub struct FetchMessageResponse {
}

pub struct DynamoStorage {
ddb: Rc<DynamoDbClient>,
ddb: Rc<Box<DynamoDb>>,
}

impl DynamoStorage {
pub fn new() -> DynamoStorage {
let region = env::var("AWS_LOCAL_DYNAMODB")
.map(|endpoint| Region::Custom {
endpoint,
name: "env_var".to_string(),
})
.unwrap_or(Region::default());
DynamoStorage {
ddb: Rc::new(DynamoDbClient::simple(region)),
}
let ddb: Box<DynamoDb> = if let Ok(endpoint) = env::var("AWS_LOCAL_DYNAMODB") {
Box::new(DynamoDbClient::new(
RequestDispatcher::default(),
StaticProvider::new_minimal("BogusKey".to_string(), "BogusKey".to_string()),
Region::Custom {
name: "us-east-1".to_string(),
endpoint,
},
))
} else {
Box::new(DynamoDbClient::simple(Region::default()))
};
DynamoStorage { ddb: Rc::new(ddb) }
}

pub fn increment_storage(
Expand Down Expand Up @@ -357,7 +363,7 @@ impl DynamoStorage {
}

pub fn fetch_messages(
ddb: Rc<DynamoDbClient>,
ddb: Rc<Box<DynamoDb>>,
table_name: &str,
uaid: &Uuid,
limit: u32,
Expand Down Expand Up @@ -439,7 +445,7 @@ impl DynamoStorage {
}

pub fn fetch_timestamp_messages(
ddb: Rc<DynamoDbClient>,
ddb: Rc<Box<DynamoDb>>,
table_name: &str,
uaid: &Uuid,
timestamp: Option<u64>,
Expand Down
9 changes: 0 additions & 9 deletions boto-compose.cfg

This file was deleted.

3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
environment:
- LOCAL_HOSTNAME=localhost
- ROUTER_HOSTNAME=autopush
- AWS_LOCAL_DYNAMODB=http://dynamodb:8000
- HUMAN_LOGS=true
- CRYPTO_KEY=${CRYPTO_KEY}
ports:
Expand All @@ -22,6 +23,7 @@ services:
environment:
- HUMAN_LOGS=true
- CRYPTO_KEY=${CRYPTO_KEY}
- AWS_LOCAL_DYNAMODB=http://dynamodb:8000
ports:
- "8082:8082"
links:
Expand All @@ -30,5 +32,6 @@ services:
- ./boto-compose.cfg:/etc/boto.cfg:ro
dynamodb:
image: peopleperhour/dynamodb
hostname: dynamodb
expose:
- "8000"

0 comments on commit a520338

Please sign in to comment.