{"id":15145736,"url":"https://github.com/soundcloud/sc-gaws","last_synced_at":"2025-09-29T15:31:01.845Z","repository":{"id":7646279,"uuid":"9006823","full_name":"soundcloud/sc-gaws","owner":"soundcloud","description":"Glue code to wrap around AWS and do useful things in Go","archived":true,"fork":false,"pushed_at":"2022-03-21T13:27:30.000Z","size":43,"stargazers_count":9,"open_issues_count":2,"forks_count":2,"subscribers_count":93,"default_branch":"master","last_synced_at":"2024-09-27T11:42:20.844Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soundcloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-25T13:36:16.000Z","updated_at":"2023-01-28T02:12:47.000Z","dependencies_parsed_at":"2022-09-19T11:41:43.812Z","dependency_job_id":null,"html_url":"https://github.com/soundcloud/sc-gaws","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundcloud%2Fsc-gaws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundcloud%2Fsc-gaws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundcloud%2Fsc-gaws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soundcloud%2Fsc-gaws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soundcloud","download_url":"https://codeload.github.com/soundcloud/sc-gaws/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234635011,"owners_count":18863988,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-26T11:42:22.713Z","updated_at":"2025-09-29T15:31:01.536Z","avatar_url":"https://github.com/soundcloud.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚠️ Deprecation notice: Please note that this project has been deprecated and is no longer actively maintained. If you are interested in working on this and would like to take over ownership, please [get in touch with us here](mailto:developers@soundcloud.com).\n\n---\n\n# sc-gaws\n\nGlue code to wrap around AWS and do useful things in Go.\n\n## Usage\n\n### aws/credentials\n\n```\nimport (\n    \"github.com/kr/s3\"\n    \"github.com/soundcloud/sc-gaws/aws/credentials\"\n)\n\nfunc myFunc() {\n    var credentialsProvider credentials.CredentialsProvider\n\n    // With access key and secret key\n    credentialsProvider = credentials.NewIamUserCredentials(accessKey, secretKey)\n\n    // With role name\n    var err error\n    credentialsProvider, err = credentials.NewIamRoleCredentials(role)\n    if err != nil {\n        log.Fatalf(\"Error fetching credentials for role %s: %s\", role, err)\n    }\n\n    // Create an HTTP client request\n    // req, err := http.NewRequest(...)\n\n    creds := credentialsProvider.GetCredentials()\n    keys := s3.Keys{AccessKey: creds.AccessKeyId, SecretKey: creds.SecretAccessKey, SecurityToken: creds.Token}\n    s3.Sign(req, keys)\n}\n```\n\n### aws/elasticache\n\nThis package provides a mechanism for auto-discovery of ElastiCache servers.\nIt is recommended you get the configuration data on a 60 second timer and\nkeep track of configuration version numbers, so that you can set your\nclient to use the new set of servers only when they change.\n\n```\nimport (\n    \"elasticache\"\n    \"log\"\n)\n\nvar configVersion = 0\n\nfunc updaterGoRoutine(autoDiscoveryConfigHost string) {\n    autoDiscoverer, err := elasticache.NewAutoDiscoverer(autoDiscoveryConfigHost)\n    if err != nil {\n        log.Fatal(err.Error())\n    }\n\n    for {\n        version, elastiCacheServers, err := autoDiscoverer.GetClusterConfig()\n\n        if version \u003e configVersion {\n            configVersion = version\n\n            // call SetServers on the Memcache client ServerList\n        }\n\n        time.Sleep(60 * time.Second)\n    }\n}\n```\n\n### aws and stats\n\n```\nimport (\n    \"github.com/soundcloud/sc-gaws/aws\"\n    \"github.com/soundcloud/sc-gaws/stats\"\n)\n\nfunc myFunc() {\n    metricsChan := make(chan stats.Metric)\n\n    // You'll need to set up the credentials as per the above section.\n    s := stats.NewStats(\n        aws.AwsStatsPusher{\n            credentialsProvider,\n            \"MyMetricNameSpace\",\n        },\n        10, // number of samples to accumulate as one data point\n    )\n\n    go s.AccumulateAndPush(60*time.Second, metricsChan) // Push stats once every minute\n\n    metricsChan \u003c- stats.Metric{\"NumberOfWidgetsCount\", float32(1.0), \"Count\", time.Now()}\n\n    begin := time.Now()\n    // Some expensive operation\n    duration := float32(time.Since(begin) / time.Millisecond)\n    metricsChan \u003c- stats.Metric{\"WidgetResponseTimeMs\", duration, \"Average\", time.Now()}\n}\n```\n\n### aws/cloudfront\n\nWhen using CloudFront with Restrict Viewer Access option, every URL needs to be signed.\n\nThis package implements:\n\n- [Canned Policy signing](http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-creating-signed-url-canned-policy.html).\n- [Custom Policy signing](http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-creating-signed-url-custom-policy.html).\n\n_Please note:_ Due to performance reason we are using openssl c bindings.\n\nIt requires a valid [CloudFront private key](http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-trusted-signers.html#private-content-creating-cloudfront-key-pairs).\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"time\"\n\n    \"github.com/soundcloud/sc-gaws/aws/cloudfront\"\n)\n\nfunc main() {\n    privateKey, _ := cloudfront.NewRSAPrivateKeyFromFile(\"pk-KeyPairId.pem\")\n\n    baseURL := \"http://cloudfront-foobar.com/my-sweet-file.mp3\"\n    wildcardURL := \"*/my-sweet-file.mp3\"\n    expiresAt := time.Now().Add(time.Duration(2 * time.Minute))\n\n    // Provide your URL and desired expiry time for a canned policy.\n    cannedPolicy := cloudfront.NewCannedPolicy(baseURL, expiresAt)\n\n    // Or provide your URL, an expiry time and an optional start time and\n    // source IP address restriction for a custom policy.\n    startsAt := time.Now()\n    sourceIP := \"192.0.2.1\"\n    customPolicy := cloudfront.NewCustomPolicy(wildcardURL, expiresAt).AddStartTime(startsAt).AddSourceIP(sourceIP)\n\n    cannedSignature, _ := cloudfront.SignPolicy(privateKey, cannedPolicy)\n    customSignature, _ := cloudfront.SignPolicy(privateKey, customPolicy)\n\n    queryParams := \"myparam=1\"\n\n    fmt.Printf(\"%s?%s\u0026%s\", baseURL, queryParams, cannedSignature)\n    fmt.Printf(\"%s?%s\u0026%s\", baseURL, queryParams, customSignature)\n}\n```\n\nOnce you have generated a signature, you can append it to your base URL to\ngenerate a working CloudFront URL based on the supplied parameters.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoundcloud%2Fsc-gaws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoundcloud%2Fsc-gaws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoundcloud%2Fsc-gaws/lists"}