- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个连接到 Github 存储库的 AWS CodeBuild 项目,每次新提交时,它都会根据预定义模板创建一个新的 CloudFormation 堆栈。完整模板can be found here .
CodeBuild 项目将其作为其构建命令:
version: 0.2
phases:
install:
runtime-versions:
nodejs: 12
pre_build:
commands:
- NODE_ENV=development npm install
- npm run makeScriptsExecutable
build:
commands:
- stackName="stack-$CODEBUILD_RESOLVED_SOURCE_VERSION"
- apiGatewayName="gateway-$CODEBUILD_RESOLVED_SOURCE_VERSION"
- FUNCTION_NAME="lambda-$CODEBUILD_RESOLVED_SOURCE_VERSION"
- S3_ASSETS_BUCKET="s3-$CODEBUILD_RESOLVED_SOURCE_VERSION"
- S3_ASSETS_BUCKET_URI="s3://$S3_ASSETS_BUCKET"
- DOMAIN_NAME="$CODEBUILD_RESOLVED_SOURCE_VERSION.guacchain.com"
- BASE_NAME="prod"
- echo "S3_ASSETS_BUCKET_URI value here:"
- echo $S3_ASSETS_BUCKET_URI
- TEMPLATE_URL=https://s3-external-1.amazonaws.com/cf-templates-1npj2t2ifo384-us-east-1/2020146JeV-stack2.yaml
- aws cloudformation create-stack --stack-name $stackName --template-url $TEMPLATE_URL --parameters ParameterKey=apiGatewayStageName,ParameterValue=$BASE_NAME ParameterKey=lambdaFunctionName,ParameterValue=$FUNCTION_NAME ParameterKey=s3BucketName,ParameterValue=$S3_ASSETS_BUCKET ParameterKey=domainName,ParameterValue=$DOMAIN_NAME ParameterKey=subdomain,ParameterValue=$CODEBUILD_RESOLVED_SOURCE_VERSION --capabilities CAPABILITY_IAM
- sleep 45
- sed -i "s/COMMIT_ID/$CODEBUILD_RESOLVED_SOURCE_VERSION/g" .babelrc
- NODE_ENV=production npm run start
- NODE_ENV=production npm run build
- NODE_ENV=production npm run build:server
- NODE_ENV=production npm run deploy
我当前遇到的问题是,自从添加 AWS::Route53::RecordSet
类型的资源后,堆栈创建失败,原因是:API:route53:GetHostedZone用户:arn:aws:sts::XXXX:assumed-role/CodeBuildServiceRole/AWSCodeBuild-XXXX 无权访问此资源
。
该资源当前如下所示:
domainRecordSet:
Type: 'AWS::Route53::RecordSet'
Properties:
AliasTarget:
DNSName: !GetAtt domainNameResource.DistributionDomainName
HostedZoneId: !GetAtt domainNameResource.DistributionHostedZoneId
Type: A
HostedZoneId: !GetAtt domainNameResource.DistributionHostedZoneId
Name: !Sub '${subdomain}.guacchain.com'
subdomain
变量作为参数提供给堆栈。在堆栈创建失败之前,引用的 domainNameResource
已成功创建:
此外,CodeBuildServiceRole
也应用于 CodeBuild 项目。我认为为其提供 AdministratorAccess
、AmazonRoute53FullAccess
和 AWSCloudFormationFullAccess
策略就足够了,但显然不够!
在 IAM 权限选项卡上,它显示权限边界(未设置)
。
在“可信关系”选项卡上,“可信实体”列表中只有一行:身份提供商 codebuild.amazonaws.com
。还显示“没有与此角色相关的条件。”
必须对此 IAM 角色、Codebuild 项目或 CloudFormation 堆栈(或它们的某种组合)执行哪些操作才能成功创建 Route53 RecordSet 资源?
最佳答案
根据评论,问题是对第二个 HostedZoneId
的分配不正确:
HostedZoneId: !GetAtt domainNameResource.DistributionHostedZoneId
它应该是OP控制的托管区域的ID,而不是AWS拥有的CloudFront发行版的托管区域。这解释了错误消息 - 您无权修改 AWS 拥有的托管区域。
关于amazon-web-services - 云形成路线53 :GetHostedZone User is not authorized to access this resource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61995711/
我正在创建一个 AWS Cloudformation 堆栈,在其中将记录集添加到现有 Route53 托管区域。资源指定如下(YAML 格式): DNS: Type: AWS::Route53
我有一个连接到 Github 存储库的 AWS CodeBuild 项目,每次新提交时,它都会根据预定义模板创建一个新的 CloudFormation 堆栈。完整模板can be found here
我是一名优秀的程序员,十分优秀!