Aws :: ElasticTranscoder :: Errors :: AccessDeniedException
我使用AWS ElasticTranscoder服务创建工作并转换视频。
在创建AWS ElasticTranscoder作业时遇到错误。
Aws :: ElasticTranscoder :: Errors :: AccessDeniedException(用户: arn:aws:iam :: 119945600465:user / s3_bucket_user无权执行以下操作: 在资源上执行:elastictranscoder:CreateJob: arn:aws:elastictranscoder:us-east-1:119945600465:pipeline / 1464161888836-rawwl7)
日志文件:
I, [2018-06-22T11:43:22.942346 #17751] INFO -- : Completed 500 Internal Server Error in 100560ms (ActiveRecord: 29.3ms)
F, [2018-06-22T11:43:22.942944 #17751] FATAL -- :
F, [2018-06-22T11:43:22.942988 #17751] FATAL -- : Aws::ElasticTranscoder::Errors::AccessDeniedException (User: arn:aws:iam::119945600465:user/s3_bucket_user is not authorized to perform: elastictranscoder:CreateJob on resource: arn:aws:elastictranscoder:us-east-1:119945600465:pipeline/1464161888836-rawwl7):
F, [2018-06-22T11:43:22.943032 #17751] FATAL -- :
F, [2018-06-22T11:43:22.943081 #17751] FATAL -- : app/services/aws/upstge/transcode_video.rb:42:in `create_job'
app/services/aws/upstge/transcode_video.rb:11:in `call'
app/jobs/aws/upstge/video_preview_transcoder.rb:9:in `perform'
app/controllers/video_editors_controller.rb:38:in `create'
transcode_video.rb文件:
module Aws
module Name
class TranscodeVideo
def initialize(video, job_response: nil)
@video = video
@job_response = job_response
end
def call
resolutions = collect_resolutions
create_job resolutions
end
private
def collect_resolutions
logger = Logger.new('log/aws_job.log')
if @job_response.blank?
Array(wallet[:transcoder][:stage_zero_mode])
else
wallet[:transcoder][:modes][:keys].tap { |keys| keys.delete(wallet[:transcoder][:stage_zero_mode]) }
.delete_if { |res| res.to_i > max_resolution }
end
end
def create_job(resolutions)
logger = Logger.new('log/aws_job.log')
return :no_available_resolutions if resolutions.blank?
resolutions.each do |res|
mode = wallet[:transcoder][:modes][:"360p"]
logger.info "------------- mode ----------"
logger.info mode
options[:outputs].push({ key: "#{mode[:prefix]}/#{'51507dd0-aa55-42d4-8e89-33264f24bf1d'}#{mode[:extension]}",
thumbnail_pattern: "#{mode[:prefix]}/#{'51507dd0-aa55-42d4-8e89-33264f24bf1d'}---{count}",
preset_id: mode[:preset] })
end
logger.info "-----------------------"
logger.info options
transcoder.create_job(options)
:started
end
def options
@options ||= { pipeline_id: wallet[:transcoder][:pipeline],
input: { key: s3_object },
outputs: [] }
end
def s3_object
@video.s3_object
end
def wallet
@wallet ||= Rails.application.secrets.aws
end
def transcoder
@transcoder ||= Aws::ElasticTranscoder::Client.new access_key_id: wallet[:access_key_id],
secret_access_key: wallet[:secret_access_key],
region: wallet[:region]
end
def max_resolution
@max_resolution ||= (
response = transcoder.read_job(id: @job_response.job_id)
response.job.input.detected_properties.height
)
end
end
end
end
答案 0 :(得分:1)
错误消息显示:
s3_bucket_user is not authorized to perform: elastictranscoder:CreateJob
您的 s3_bucket_user 仅具有使用Amazon S3的权限。该错误消息表明您的代码正在尝试在Elastic Transcoder上调用CreateJob()
命令。因此, s3_bucket_user 需要elastictranscoder:CreateJob
权限。
如果您想轻松地做到这一点,只需给他们提供AmazonElasticTranscoder_JobsSubmitter
政策或您认为合适的另一项政策即可。