C # AWS CDK 프로젝트에서 태그를 작동 시키려고하는데 Depreciated 구문을 제외하고는 아무것도 작동하지 않는 것 같습니다. 예를 들어 다음 코드에서 :
using Amazon.CDK;
using Amazon.CDK.AWS.S3;
namespace HelloCdk
{
public class HelloCdkStack : Stack
{
internal HelloCdkStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
{
// The code that defines your stack goes here
var g_bucket = new Bucket(this, "GameContent", new BucketProps
{
Versioned = false,
PublicReadAccess = true,
AutoDeleteObjects = true, //delete and
RemovalPolicy = RemovalPolicy.DESTROY, //destroy bucket when CF Stack deleted.
WebsiteIndexDocument = "index.html",
WebsiteErrorDocument = "index.html"
});
Tag.Add(g_bucket, "key", "value");
}
}
}
위의 코드는 cdk synth
명령을 실행 하면 성공합니다 . 그러나 다음과 같은 경고 메시지가 나타납니다.
경고 CS0618 : 'Tag.Add (Construct, string, string, ITagProps?)'는 더 이상 사용되지 않습니다. 'use "Tags.of (scope) .add ()"'
그러나 "Tags.of ..."를 사용하려고하면 cdk synth
명령에서 다음 오류가 발생합니다.
오류 CS1061 : 'TagManager'에 'of'에 대한 정의가 없으며 액세스 가능한 확장 메서드 'of'가 없습니다.
권장되는 태그 지정 방식이 작동하려면 무엇을 변경해야합니까?
Tags.of
.NET에 대한 이러한 메서드가 정의되어 있지 않으므로 소스 코드를 컴파일해서는 안됩니다.
문서 지정-https Tags.Of
: //docs.aws.amazon.com/cdk/latest/guide/tagging.html
Tags.Of (myConstruct) .Add ( "key", "value");
(!) 스택 객체에는 Tags 속성이 있으므로 스택의 Tags 속성에 액세스하지 말고 Tags 클래스에 액세스해야합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다