Tag: amazon web services

基于浏览器的上传使用POST

我正在尝试使用带有AWS签名版本4的POST创建客户端上传。 根据文件 当我在服务器端生成签名时,我得到与此示例页面中提到的AWS签名完全匹配。 但是,当我使用它上传页面时,我收到此错误: SignatureDoesNotMatch我们计算的请求签名与您提供的签名不匹配。 检查您的密钥和签名方法 这是我用过的代码: OpenSSL::HMAC.hexdigest(‘sha256’, signing_key(string_to_sign), string_to_sign) # step 2 in the aws documentation def signing_key(encoded_policy) # generate the correct date date = extract_encoded_policy_date(encoded_policy) date = time_adjust(date) # encode all the fields by the algorithm date_key = OpenSSL::HMAC.digest(‘sha256’,”AWS4#{@secret_access_key}”, date.strftime(“%Y%m%d”)) date_region_key = OpenSSL::HMAC.digest(‘sha256’,date_key, @region) date_region_service_key = OpenSSL::HMAC.digest(‘sha256’,date_region_key, @service) signing_key = OpenSSL::HMAC.digest(‘sha256’,date_region_service_key, ‘aws4_request’) signing_key […]

无法使用HMAC SHA256从示例中重现AWS签名

我正在关注这个例子 http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html 并试图重现64个字符串的签名,他们声称… aeeed9bbccd4d02ee5c0109b86d86835f995330da4c265957d157751f604d404 我已成功匹配Canonical Request的hex digeset,并确认StringToSign字符串是正确的。 最后一部分是计算signing_key和签名。 这是我使用提供的ruby函数’getSignatureKey’击中路障的地方 http://docs.aws.amazon.com/general/latest/gr/signature-v4-examples.html#signature-v4-examples-ruby signing_key = getSignatureKey secret_access_key, current_date, region, aws_service signature = OpenSSL::HMAC.digest(‘sha256’, signing_key, string_to_sign) def getSignatureKey key, dateStamp, regionName, serviceName kDate = OpenSSL::HMAC.digest(‘sha256’, “AWS4” + key, dateStamp) kRegion = OpenSSL::HMAC.digest(‘sha256’, kDate, regionName) kService = OpenSSL::HMAC.digest(‘sha256’, kRegion, serviceName) kSigning = OpenSSL::HMAC.digest(‘sha256′, kService, “aws4_request”) kSigning end ‘signature’的当前输出是这个奇怪的字符序列。 ٻ . […]

因使用rb-readline而导致使用Elastic Beanstalk将rails 5应用程序部署到AWS

我正在尝试使用弹性beanstalk将我的代码部署到AWS,但在部署时仍然遇到错误。 我添加了一个gem’rb-readline’,当我检查日志时,我发现这个gem在部署时出错了。 我不记得添加gem’rb-readline’修复了什么错误,但我不知道删除gem会不会解决这个问题。 以下是gem的链接: https : //github.com/ConnorAtherton/rb-readline 这是部署中的错误日志。 Application update failed at 2017-10-24T19:27:36Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/11_asset_compilation.sh failed. ++ /opt/elasticbeanstalk/bin/get-config container -k script_dir + EB_SCRIPT_DIR=/opt/elasticbeanstalk/support/scripts ++ /opt/elasticbeanstalk/bin/get-config container -k app_staging_dir + EB_APP_STAGING_DIR=/var/app/ondeck ++ /opt/elasticbeanstalk/bin/get-config container -k app_user + EB_APP_USER=webapp ++ /opt/elasticbeanstalk/bin/get-config container -k support_dir + EB_SUPPORT_DIR=/opt/elasticbeanstalk/support + . /opt/elasticbeanstalk/support/envvars ++ export […]

加载两个名称相同的Ruby Modules / Gems

我正在尝试使用两个Gems来访问Amazon Web Services(AWS)。 一个是亚马逊’aws-sdk’,另一个是’amazon-ec2’。 我正在使用第二个,因为aws-sdk没有涵盖亚马逊服务的cloudwatch部分。 问题是两者都加载到同一名称空间。 require ‘aws-sdk’ # aws-sdk gem require ‘AWS’ # amazon-ec2 gem config = {:access_key_id => ‘abc’, :secret_key => ‘xyz’} # start using the API with aws-sdk ec2 = AWS::EC2.new(config) # start using the API for anazon-ec2 cw = AWS::Cloudwatch::Base.new(config) 现在,这可以理解地在最后一行引发错误,因为AWS模块指向第一个必需的库,在本例中为aws-sdk。 NameError: uninitialized constant AWS::Cloudwatch 那么,我可以将其中一个加载到另一个名称空间中吗? 就像是 require ‘aws-sdk’, ‘AWS_SDK’ require […]

使用AWS Elastic Beanstalk和Ruby容器设置私有Github访问

通过最近使用Git设置用于Ruby部署的AWS Elastic Beanstalk的教程 ,我只是从我的CI服务器设置了一个Elastic Beanstalk环境。 但是,应用程序无法启动。 我浏览了日志,发现bundle install失败并显示错误消息。 获取git@github.com:example / private-repository.git主机密钥validation失败。 致命:远程终端意外挂断[31mGit错误:命令git clone ‘git@github.com:example/private-repository.git’ “/var/app/ondeck/vendor/cache/ruby/1.9.1/cache/bundler/git/private-repository-e4bbe6c2b13bb62664e39e345c1b01d80017934c” –bare –no-hardlinks clone’git@github.com git clone ‘git@github.com:example/private-repository.git’ “/var/app/ondeck/vendor/cache/ruby/1.9.1/cache/bundler/git/private-repository-e4bbe6c2b13bb62664e39e345c1b01d80017934c” –bare –no-hardlinks目录/ var / app / ondeck中的git clone ‘git@github.com:example/private-repository.git’ “/var/app/ondeck/vendor/cache/ruby/1.9.1/cache/bundler/git/private-repository-e4bbe6c2b13bb62664e39e345c1b01d80017934c” –bare –no-hardlinks失败。[0m 我的Rails应用程序的Gemfile包含对我在Github上拥有的几个私有存储库上托管的gemified插件的引用。 就像是 gem’partgemname’,: git =>’git@github.com:example / private-repository.git’ 我遇到过与Capistrano部署类似的问题,这些问题通过设置ssh_options[:forward_agent] = true 。 AWS Elastic Beanstalk Ruby容器通过放在.ebextensions下的自定义.config文件支持自定义配置。 在这种情况下,设置SSH转发代理会有所帮助吗? 在启动Elastic Beanstalk环境时,还有其他替代方法可以访问私有Github存储库吗? 更新1:我刚刚检查了启动bundle install的用户。 发现脚本/opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh以root用户/opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh启动bundle […]

使用带ruby的memcache客户端

我试图使用memcache-client连接创建的amazon elastiCache集群端点。 但我得到了错误 MemCache::MemCacheError: No connection to server (testcachecluster.u098ed.cfg.us e1.cache.amazonaws.com:11211 DEAD (Timeout::Error: execution expired), will retr y at 2013-06-21 11:34:15 +0530) from C:/ProgramData/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/me mcache-client-1.8.5/lib/memcache.rb:863:in `with_socket_management’ from C:/ProgramData/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/me mcache-client-1.8.5/lib/memcache.rb:370:in `block in set’ from C:/ProgramData/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/me mcache-client-1.8.5/lib/memcache.rb:886:in `with_server’ from C:/ProgramData/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/me mcache-client-1.8.5/lib/memcache.rb:361:in `set’ from (irb):5 from C:/ProgramData/RailsInstaller/Ruby1.9.3/bin/irb:12:in `’ 但是正确使用amazon elastiCache集群端点的localhost instread。 irb(main):006:0> m = MemCache.new(‘localhost:11211’) => irb(main):007:0> m.set ‘abc’, […]